Revert using fasthttp library to net/http

This commit is contained in:
Cameron Sparr
2017-01-11 16:01:32 +00:00
parent f5d892d7d3
commit a36fd375de
6 changed files with 102 additions and 74 deletions

View File

@@ -140,3 +140,27 @@ func TestHTTPError_DatabaseNotFound(t *testing.T) {
require.Error(t, err)
require.NoError(t, i.Close())
}
// field type conflict does not return an error, instead we
func TestHTTPError_FieldTypeConflict(t *testing.T) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/write":
w.WriteHeader(http.StatusNotFound)
w.Header().Set("Content-Type", "application/json")
fmt.Fprintln(w, `{"results":[{}],"error":"field type conflict: input field \"value\" on measurement \"test\" is type integer, already exists as type float dropped=1"}`)
}
}))
defer ts.Close()
i := InfluxDB{
URLs: []string{ts.URL},
Database: "test",
}
err := i.Connect()
require.NoError(t, err)
err = i.Write(testutil.MockMetrics())
require.NoError(t, err)
require.NoError(t, i.Close())
}