Return status code 200 for measurement not found errors

pull/1999/head
Cory LaNou 2015-03-18 09:29:45 -06:00
parent 4e77faf619
commit 894de34245
2 changed files with 21 additions and 1 deletions

View File

@ -440,7 +440,8 @@ func isAuthorizationError(err error) bool {
}
func isMeasurementNotFoundError(err error) bool {
return (err.Error() == "measurement not found")
s := err.Error()
return strings.HasPrefix(s, "measurement") && strings.HasSuffix(s, "not found")
}
func isFieldNotFoundError(err error) bool {

View File

@ -136,6 +136,25 @@ func TestBatchWrite_UnmarshalRFC(t *testing.T) {
}
}
// Ensure that even if a measurement is not found, that the status code is still 200
func TestHandler_ShowMeasurementsNotFound(t *testing.T) {
c := test.NewMessagingClient()
defer c.Close()
srvr := OpenAuthlessServer(c)
srvr.CreateDatabase("foo")
srvr.CreateRetentionPolicy("foo", influxdb.NewRetentionPolicy("bar"))
srvr.SetDefaultRetentionPolicy("foo", "bar")
s := NewHTTPServer(srvr)
defer s.Close()
status, body := MustHTTP("GET", s.URL+`/query`, map[string]string{"q": "SHOW SERIES from bin", "db": "foo"}, nil, "")
if status != http.StatusOK {
t.Fatalf("unexpected status: %d", status)
} else if body != `{"results":[{"error":"measurement \"bin\" not found"}]}` {
t.Fatalf("unexpected body: %s", body)
}
}
func TestHandler_Databases(t *testing.T) {
c := test.NewMessagingClient()
defer c.Close()