From 64907ecc42ea17acbd68ccdd4b32d560e0c673e0 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 7 Nov 2024 16:01:03 +0100 Subject: pkg/manager: add test for all HTTP templates It's easy to make mistakes in templates that lead to runtime panics. Catch them during testing. This required to convert some pointers to values for things that must not be nil. Otherwise the randomized test can pass nil for the objects and templates fail. --- pkg/manager/http_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 pkg/manager/http_test.go (limited to 'pkg/manager/http_test.go') diff --git a/pkg/manager/http_test.go b/pkg/manager/http_test.go new file mode 100644 index 000000000..a99c9f4a0 --- /dev/null +++ b/pkg/manager/http_test.go @@ -0,0 +1,22 @@ +// Copyright 2024 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package manager + +import ( + "io" + "testing" + + "github.com/google/syzkaller/pkg/testutil" +) + +func TestHttpTemplates(t *testing.T) { + for _, typ := range templTypes { + t.Run(typ.title, func(t *testing.T) { + data := testutil.RandValue(t, typ.data) + if err := typ.templ.Execute(io.Discard, data); err != nil { + t.Fatal(err) + } + }) + } +} -- cgit mrf-deployment