Add unit test for WHERE string fields

pull/1814/head
Philip O'Toole 2015-03-02 16:16:30 -08:00
parent bab0389293
commit 9d5ef5fc7a
1 changed files with 40 additions and 0 deletions

View File

@ -1501,6 +1501,46 @@ func TestHandler_serveWriteSeriesWhereIntField(t *testing.T) {
}
}
func TestHandler_serveWriteSeriesWhereStringField(t *testing.T) {
srvr := OpenAuthlessServer(NewMessagingClient())
srvr.CreateDatabase("foo")
srvr.CreateRetentionPolicy("foo", influxdb.NewRetentionPolicy("bar"))
srvr.SetDefaultRetentionPolicy("foo", "bar")
s := NewHTTPServer(srvr)
defer s.Close()
status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "logs", "tags": {"host": "server01"},"fields": {"event": "disk full"}}]}`)
if status != http.StatusOK {
t.Fatalf("unexpected status: %d", status)
}
time.Sleep(100 * time.Millisecond) // Ensure data node picks up write.
srvr.Restart() // Ensure data is queryable across restarts.
query := map[string]string{"db": "foo", "q": "select event from logs where event = 'nonsense'"}
status, body := MustHTTP("GET", s.URL+`/query`, query, nil, "")
if status != http.StatusOK {
t.Logf("query %s\n", query)
t.Log(body)
t.Errorf("unexpected status: %d", status)
}
if string(body) != `{"results":[{}]}` {
t.Fatalf("unexpected results, got %s", string(body))
}
query = map[string]string{"db": "foo", "q": "select event from logs where event = 'disk full'"}
status, body = MustHTTP("GET", s.URL+`/query`, query, nil, "")
if status != http.StatusOK {
t.Logf("query %s\n", query)
t.Log(body)
t.Errorf("unexpected status: %d", status)
}
if string(body) != `{"results":[{}]}` {
t.Fatalf("unexpected results, got %s", string(body))
}
}
func TestHandler_serveWriteSeriesBatch(t *testing.T) {
srvr := OpenAuthlessServer(NewMessagingClient())
srvr.CreateDatabase("foo")