aboutsummaryrefslogtreecommitdiff
path: root/middleware/metrics/setup_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'middleware/metrics/setup_test.go')
-rw-r--r--middleware/metrics/setup_test.go23
1 files changed, 18 insertions, 5 deletions
diff --git a/middleware/metrics/setup_test.go b/middleware/metrics/setup_test.go
index 231830c89..2971634f9 100644
--- a/middleware/metrics/setup_test.go
+++ b/middleware/metrics/setup_test.go
@@ -10,19 +10,32 @@ func TestPrometheus(t *testing.T) {
tests := []struct {
input string
shouldErr bool
+ addr string
}{
- {`prometheus`, false},
- {`prometheus {}`, false}, // TODO(miek): should be true
- {`prometheus /foo`, false}, // TODO(miek): should be true
- {`prometheus localhost:53`, false},
+ // oks
+ {`prometheus`, false, "localhost:9153"},
+ {`prometheus localhost:53`, false, "localhost:53"},
+ // fails
+ {`prometheus {}`, true, ""},
+ {`prometheus /foo`, true, ""},
}
for i, test := range tests {
c := caddy.NewTestController("dns", test.input)
- err := setup(c)
+ m, err := prometheusParse(c)
if test.shouldErr && err == nil {
t.Errorf("Test %v: Expected error but found nil", i)
+ continue
} else if !test.shouldErr && err != nil {
t.Errorf("Test %v: Expected no error but found error: %v", i, err)
+ continue
+ }
+
+ if test.shouldErr {
+ continue
+ }
+
+ if test.addr != m.Addr {
+ t.Errorf("Test %v: Expected address %s but found: %s", i, test.addr, m.Addr)
}
}
}