Skip to content

Commit

Permalink
fix: unit test using wrong sql
Browse files Browse the repository at this point in the history
  • Loading branch information
huskar-t committed Dec 2, 2024
1 parent 7b550ca commit 3b36a59
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 2 additions & 2 deletions plugin/nodeexporter/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestNodeExporter_Gather(t *testing.T) {
defer func() {
wrapper.TaosClose(conn)
}()
err = exec(conn, "drop database if exists node_exporter")
err = exec(conn, "create database if not exists node_exporter precision 'ns'")
assert.NoError(t, err)
err = exec(conn, "use node_exporter")
assert.NoError(t, err)
Expand All @@ -70,7 +70,7 @@ func TestNodeExporter_Gather(t *testing.T) {
err = n.Start()
assert.NoError(t, err)
time.Sleep(time.Second * 2)
values, err := query(conn, "select last(`value`) as `value` from node_exporter.go_gc_duration_seconds;")
values, err := query(conn, "select last(`value`) as `value` from node_exporter.test_metric;")
assert.NoError(t, err)
assert.Equal(t, float64(1), values[0][0])
err = n.Stop()
Expand Down
2 changes: 1 addition & 1 deletion plugin/opentsdbtelnet/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestPlugin(t *testing.T) {
defer func() {
wrapper.TaosClose(conn)
}()
err = exec(conn, "drop database if exists opentsdb_telnet")
err = exec(conn, "create database if not exists opentsdb_telnet")
assert.NoError(t, err)
err = p.Init(nil)
assert.NoError(t, err)
Expand Down
11 changes: 3 additions & 8 deletions plugin/statsd/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestStatsd(t *testing.T) {
defer func() {
wrapper.TaosClose(conn)
}()
err = exec(conn, "drop database if exists statsd")
err = exec(conn, "create database if not exists statsd")
assert.NoError(t, err)
err = p.Init(nil)
assert.NoError(t, err)
Expand All @@ -58,13 +58,8 @@ func TestStatsd(t *testing.T) {
assert.NoError(t, err)
time.Sleep(time.Second)
defer func() {
r := wrapper.TaosQuery(conn, "drop database if exists statsd")
code := wrapper.TaosError(r)
if code != 0 {
errStr := wrapper.TaosErrorStr(r)
t.Error(errors.NewError(code, errStr))
}
wrapper.TaosFreeResult(r)
err = exec(conn, "drop database if exists statsd")
assert.NoError(t, err)
}()
values, err := query(conn, "select last(`value`) from statsd.`foo`")
assert.NoError(t, err)
Expand Down

0 comments on commit 3b36a59

Please sign in to comment.