summaryrefslogtreecommitdiff
path: root/caddyconfig/httpcaddyfile/httptype_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'caddyconfig/httpcaddyfile/httptype_test.go')
-rw-r--r--caddyconfig/httpcaddyfile/httptype_test.go50
1 files changed, 49 insertions, 1 deletions
diff --git a/caddyconfig/httpcaddyfile/httptype_test.go b/caddyconfig/httpcaddyfile/httptype_test.go
index ae4f042..3b69677 100644
--- a/caddyconfig/httpcaddyfile/httptype_test.go
+++ b/caddyconfig/httpcaddyfile/httptype_test.go
@@ -1,6 +1,54 @@
package httpcaddyfile
-import "testing"
+import (
+ "testing"
+
+ "github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
+)
+
+func TestServerType(t *testing.T) {
+ for i, tc := range []struct {
+ input string
+ expectWarn bool
+ expectError bool
+ }{
+ {
+ input: `http://localhost
+ @debug {
+ query showdebug=1
+ }
+ `,
+ expectWarn: false,
+ expectError: false,
+ },
+ {
+ input: `http://localhost
+ @debug {
+ query bad format
+ }
+ `,
+ expectWarn: false,
+ expectError: true,
+ },
+ } {
+
+ adapter := caddyfile.Adapter{
+ ServerType: ServerType{},
+ }
+
+ _, warnings, err := adapter.Adapt([]byte(tc.input), nil)
+
+ if len(warnings) > 0 != tc.expectWarn {
+ t.Errorf("Test %d warning expectation failed Expected: %v, got %v", i, tc.expectWarn, warnings)
+ continue
+ }
+
+ if err != nil != tc.expectError {
+ t.Errorf("Test %d error expectation failed Expected: %v, got %s", i, tc.expectError, err)
+ continue
+ }
+ }
+}
func TestSpecificity(t *testing.T) {
for i, tc := range []struct {