-
Notifications
You must be signed in to change notification settings - Fork 1
/
namespaces_test.go
58 lines (47 loc) · 1.24 KB
/
namespaces_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
53
54
55
56
57
58
package control
import (
"fmt"
"math/rand"
"testing"
"github.com/stretchr/testify/assert"
)
func TestNamespaces(t *testing.T) {
client, _ := newTestClient(t)
app := newTestApp(t, &client)
name := "test-namespace-" + fmt.Sprint(rand.Uint64())
namespace := Namespace{
ID: name,
Authenticated: false,
Persisted: false,
PersistLast: false,
PushEnabled: false,
TlsOnly: false,
ExposeTimeserial: false,
BatchingEnabled: false,
}
n, err := client.CreateNamespace(app.ID, &namespace)
assert.NoError(t, err)
assert.Equal(t, namespace, n)
namespaces, err := client.Namespaces(app.ID)
assert.NoError(t, err)
assert.NotEmpty(t, namespaces)
namespace = Namespace{
ID: namespace.ID,
Authenticated: true,
Persisted: true,
PersistLast: true,
PushEnabled: true,
TlsOnly: true,
ExposeTimeserial: true,
BatchingEnabled: true,
BatchingPolicy: "simple",
BatchingInterval: BatchingInterval(100),
}
n, err = client.UpdateNamespace(app.ID, &namespace)
assert.NoError(t, err)
assert.Equal(t, namespace, n)
err = client.DeleteNamespace(app.ID, namespace.ID)
assert.NoError(t, err)
err = client.DeleteApp(app.ID)
assert.NoError(t, err)
}