aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/manager/http_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-11-07 16:01:03 +0100
committerDmitry Vyukov <dvyukov@google.com>2024-11-07 16:17:12 +0000
commit64907ecc42ea17acbd68ccdd4b32d560e0c673e0 (patch)
tree748f19217dca4725b4d56ce41103cff258ff7800 /pkg/manager/http_test.go
parent0e71cd2515586d7118198754ab664db6bc70f47a (diff)
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.
Diffstat (limited to 'pkg/manager/http_test.go')
-rw-r--r--pkg/manager/http_test.go22
1 files changed, 22 insertions, 0 deletions
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)
+ }
+ })
+ }
+}