Skip to content

Commit

Permalink
update tests to expect StatusNoContent
Browse files Browse the repository at this point in the history
  • Loading branch information
neonstalwart committed Apr 15, 2015
1 parent 0f3ace1 commit 894d198
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cmd/influxd/server_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ func write(t *testing.T, node *TestNode, data string) {
}
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println("BODY: ", string(body))
if resp.StatusCode != http.StatusOK {
if resp.StatusCode != http.StatusNoContent {
body, _ := ioutil.ReadAll(resp.Body)
t.Fatalf("Write to database failed. Unexpected status code. expected: %d, actual %d, %s", http.StatusOK, resp.StatusCode, string(body))
t.Fatalf("Write to database failed. Unexpected status code. expected: %d, actual %d, %s", http.StatusNoContent, resp.StatusCode, string(body))
}
}

Expand Down
20 changes: 10 additions & 10 deletions httpd/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func TestHandler_SelectTagNotFound(t *testing.T) {

// Write some data
status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "default", "points": [{"name": "bin", "tags": {"host": "server01"},"timestamp": "2009-11-10T23:00:00Z","fields": {"value": 100}}]}`)
if status != http.StatusOK {
if status != http.StatusNoContent {
t.Fatalf("unexpected status: %d", status)
}

Expand Down Expand Up @@ -1100,7 +1100,7 @@ func TestHandler_DropSeries(t *testing.T) {

status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "cpu", "tags": {"host": "server01"},"timestamp": "2009-11-10T23:00:00Z","fields": {"value": 100}}]}`)

if status != http.StatusOK {
if status != http.StatusNoContent {
t.Fatalf("unexpected status: %d", status)
}

Expand All @@ -1122,7 +1122,7 @@ func TestHandler_serveWriteSeries(t *testing.T) {

status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "default", "points": [{"name": "cpu", "tags": {"host": "server01"},"timestamp": "2009-11-10T23:00:00Z","fields": {"value": 100}}]}`)

if status != http.StatusOK {
if status != http.StatusNoContent {
t.Fatalf("unexpected status for post: %d", status)
}
query := map[string]string{"db": "foo", "q": "select * from cpu"}
Expand All @@ -1145,7 +1145,7 @@ func TestHandler_serveDump(t *testing.T) {

status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "default", "points": [{"name": "cpu", "tags": {"host": "server01"},"timestamp": "2009-11-10T23:00:00Z","fields": {"value": 100}}]}`)

if status != http.StatusOK {
if status != http.StatusNoContent {
t.Fatalf("unexpected status for post: %d", status)

}
Expand Down Expand Up @@ -1266,7 +1266,7 @@ func TestHandler_serveWriteSeries_queryHasJsonContentType(t *testing.T) {
defer s.Close()

status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "cpu", "tags": {"host": "server01"},"timestamp": "2009-11-10T23:00:00Z", "fields": {"value": 100}}]}`)
if status != http.StatusOK {
if status != http.StatusNoContent {
t.Fatalf("unexpected status: %d", status)
}
time.Sleep(100 * time.Millisecond) // Ensure data node picks up write.
Expand Down Expand Up @@ -1364,7 +1364,7 @@ func TestHandler_serveWriteSeriesNonZeroTime(t *testing.T) {
defer s.Close()

status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "cpu", "tags": {"host": "server01"},"timestamp": "2009-11-10T23:00:00Z", "fields": {"value": 100}}]}`)
if status != http.StatusOK {
if status != http.StatusNoContent {
t.Fatalf("unexpected status: %d", status)
}
time.Sleep(100 * time.Millisecond) // Ensure data node picks up write.
Expand Down Expand Up @@ -1410,7 +1410,7 @@ func TestHandler_serveWriteSeriesZeroTime(t *testing.T) {

status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "cpu", "tags": {"host": "server01"},"fields": {"value": 100}}]}`)

if status != http.StatusOK {
if status != http.StatusNoContent {
t.Fatalf("unexpected status: %d", status)
}
time.Sleep(100 * time.Millisecond) // Ensure data node picks up write.
Expand Down Expand Up @@ -1500,7 +1500,7 @@ func TestHandler_serveWriteSeriesBatch(t *testing.T) {
}
`
status, body := MustHTTP("POST", s.URL+`/write`, nil, nil, batch)
if status != http.StatusOK {
if status != http.StatusNoContent {
t.Log(body)
t.Fatalf("unexpected status: %d", status)
}
Expand Down Expand Up @@ -1547,7 +1547,7 @@ func TestHandler_serveWriteSeriesFieldTypeConflict(t *testing.T) {
defer s.Close()

status, _ := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "bar", "points": [{"name": "cpu", "tags": {"host": "server01"},"fields": {"value": 100}}]}`)
if status != http.StatusOK {
if status != http.StatusNoContent {
t.Fatalf("unexpected status: %d", status)
}

Expand Down Expand Up @@ -1655,7 +1655,7 @@ func TestHandler_ChunkedResponses(t *testing.T) {
status, errString := MustHTTP("POST", s.URL+`/write`, nil, nil, `{"database" : "foo", "retentionPolicy" : "bar", "points": [
{"name": "cpu", "tags": {"host": "server01"},"timestamp": "2009-11-10T23:00:00Z", "fields": {"value": 100}},
{"name": "cpu", "tags": {"host": "server02"},"timestamp": "2009-11-10T23:30:00Z", "fields": {"value": 25}}]}`)
if status != http.StatusOK {
if status != http.StatusNoContent {
t.Fatalf("unexpected status: %d - %s", status, errString)
}
time.Sleep(100 * time.Millisecond) // Ensure data node picks up write.
Expand Down

0 comments on commit 894d198

Please sign in to comment.