cleanup unit test code a bit

pull/3986/head
Preetha Appan 7 years ago
parent c87699abf2
commit 2eed7766a8
No known key found for this signature in database
GPG Key ID: 9F7C19990A50EAFC

@ -18,11 +18,28 @@ var extraTestEndpoints = map[string][]string{
"/v1/query/xxx/explain": []string{"GET"}, "/v1/query/xxx/explain": []string{"GET"},
} }
// certain endpoints can't be unit tested. // These endpoints are ignored in unit testing for response codes
var ignoredEndpoints = []string{"/v1/status/peers","/v1/agent/monitor", "/v1/agent/reload" }
// These have custom logic
var customEndpoints = []string{"/v1/query", "/v1/query/"}
// includePathInTest returns whether this path should be ignored for the purpose of testing its response code
func includePathInTest(path string) bool { func includePathInTest(path string) bool {
var hanging = path == "/v1/status/peers" || path == "/v1/agent/monitor" || path == "/v1/agent/reload" // these hang ignored := false
var custom = path == "/v1/query" || path == "/v1/query/" // these have custom logic for _, p := range ignoredEndpoints {
return !(hanging || custom) if p == path {
ignored = true
break
}
}
for _, p := range customEndpoints {
if p == path {
ignored = true
break
}
}
return !ignored
} }
func TestHTTPAPI_MethodNotAllowed_OSS(t *testing.T) { func TestHTTPAPI_MethodNotAllowed_OSS(t *testing.T) {

Loading…
Cancel
Save