-
Notifications
You must be signed in to change notification settings - Fork 1
/
categorys_test.go
50 lines (38 loc) · 1.14 KB
/
categorys_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 goidoit
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCategories(t *testing.T) {
server := idoitAPIStub()
api, err := NewLogin(server.URL, "apikey", "username", "password")
assert.Nil(t, err)
res, err := api.GetCat(1, "test")
assert.Nil(t, err)
assert.NotNil(t, res)
res, err = api.GetCat(1, 1)
assert.Nil(t, err)
assert.NotNil(t, res)
res, err = api.GetCat(1, struct{ Foo string }{"bar"})
assert.Equal(t, fmt.Errorf("query should be of type int or string"), err)
assert.Equal(t, GenericResponse{}, res)
res, err = api.CreateCat(1, "C__CAT_G_CUSTOM_FOO", nil)
assert.Nil(t, err)
assert.NotNil(t, res)
res, err = api.CreateCat(1, "C__CAT_G_TEST", nil)
assert.Nil(t, err)
assert.NotNil(t, res)
res, err = api.UpdateCat(1, "C__CAT_G_CUSTOM_FOO", nil)
assert.Nil(t, err)
assert.NotNil(t, res)
res, err = api.UpdateCat(1, "C__CAT_G_TEST", nil)
assert.Nil(t, err)
assert.NotNil(t, res)
res, err = api.DelCatObj(1, "C__CAT_G_CUSTOM_FOO", "C__CAT_E_BAR")
assert.Nil(t, err)
assert.NotNil(t, res)
res, err = api.DelCatObj(1, "C__CAT_G_TEST", "C__CAT_E_BAR")
assert.Nil(t, err)
assert.NotNil(t, res)
}