-
-
Save xNok/f2140e2b3fd928172585f1cd5f4768d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Test_write_event_with_line_protocol(t *testing.T) { | |
tests := []struct { | |
name string | |
f func(influxdb2.Client, []ThermostatSetting) | |
datas []ThermostatSetting | |
}{ | |
[...] | |
} | |
for _, tt := range tests { | |
t.Run(tt.name, func(t *testing.T) { | |
client := init_testDB(t) | |
// call function to test | |
tt.f(client, tt.datas) | |
// test can be flicky if the query is done before that data is ready in the database | |
time.Sleep(time.Millisecond * 1000) | |
// Option one: QueryTableResult | |
results := read_events_as_query_table_result(client) | |
// convert results to array to compare with data | |
resultsArr := []ThermostatSetting{} | |
for _, v := range results { | |
resultsArr = append(resultsArr, v) | |
} | |
if eq := reflect.DeepEqual(resultsArr, tt.datas); !eq { | |
t.Errorf("want %v, got %v", tt.datas, resultsArr) | |
} | |
// Option two: query raw data | |
// TODO add validation | |
read_events_as_raw_string(client) | |
client.Close() | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment