-
Notifications
You must be signed in to change notification settings - Fork 3
/
datasources_test.go
50 lines (44 loc) · 1.04 KB
/
datasources_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
package chartmogul
import (
"log"
"testing"
)
const dsTestName = "some name"
// TestImportDataSource tests creation, listing & deletion of Data Sources.
func TestImportDataSources(t *testing.T) {
if !*cm {
t.SkipNow()
return
}
ds, err := api.CreateDataSource(dsTestName)
if err != nil {
t.Error(err)
} else if ds.Name != dsTestName {
t.Errorf("Data source names don't equal - expected: %v, actual: %v", dsTestName, ds.Name)
} else if ds.UUID == "" {
t.Errorf("Data source has no UUID!")
} else if ds.CreatedAt == "" || ds.Status == "" {
t.Errorf("Data source has empty attributes! %+v", ds)
}
log.Println("Data source created.")
res, err := api.ListDataSources()
if err != nil {
t.Error(err)
}
found := false
for _, ds := range res.DataSources {
if ds.Name == dsTestName {
found = true
break
}
}
if !found {
t.Errorf("Data source not found in listing! %+v", res)
}
log.Println("Data source found.")
err = api.DeleteDataSource(ds.UUID)
if err != nil {
t.Error(err)
}
log.Println("Data source deleted.")
}