forked from rossdylan/influxdbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_test.go
52 lines (45 loc) · 1.47 KB
/
api_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package influxdbc
import "testing"
import "fmt"
func Test_createURL(t *testing.T) {
testDB := NewInfluxDB("localhost", "testdb", "tester", "password")
url := testDB.SeriesURL()
expectedURL := "http://localhost/testdb/series?u=tester&p=password"
if url != "http://localhost/db/testdb/series?u=tester&p=password" {
t.Errorf("'%s' does not match expected url, '%s'", url, expectedURL)
}
}
func Test_NewSeries(t *testing.T) {
columns := []string{"hello", "this", "is", "a", "test"}
series := NewSeries("Test", columns[0], columns[1], columns[2], columns[3], columns[4])
if series.Name != "Test" {
t.Errorf("name: '%s' != 'Test'")
}
var failed bool
failed = false
for index, value := range series.Columns {
if columns[index] != value {
failed = true
}
}
if failed {
t.Errorf("Columns did not match: %v", series.Columns)
}
}
func Test_SeriesWrite(t *testing.T) {
database := NewInfluxDB("localhost:8086", "testdb", "root", "root")
series := NewSeries("testseries", "col1", "col2")
series.AddPoint("col1", "data", "col2 data")
fmt.Println(series)
database.WriteSeries([]Series{*series})
}
func Test_Query(t *testing.T) {
database := NewInfluxDB("localhost:8086", "testdb", "root", "root")
fmt.Println(database.Query("select * from testseries;", "s"))
}
func Test_GetClusterAdmins(t *testing.T) {
testDB := NewInfluxDB("localhost:8086", "testdb", "root", "root")
testDB.AddClusterAdmin("herp", "derp")
admins, _ := testDB.GetClusterAdmins()
fmt.Println(admins)
}