MCPcopy
hub / github.com/uber/aresdb / TestNamespaceMutator

Function TestNamespaceMutator

controller/mutators/etcd/namespace_mutator_test.go:27–71  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25)
26
27func TestNamespaceMutator(t *testing.T) {
28 t.Run("list namespaces should work", func(t *testing.T) {
29 etcdStore := mem.NewStore()
30 _, err := etcdStore.Set(utils.NamespaceListKey(), &pb.EntityList{
31 Entities: []*pb.EntityName{
32 {
33 Name: "ns1",
34 },
35 },
36 })
37 assert.NoError(t, err)
38
39 // test
40 namespaceMutator := NewNamespaceMutator(etcdStore)
41 res, err := namespaceMutator.ListNamespaces()
42 assert.NoError(t, err)
43 assert.Equal(t, []string{"ns1"}, res)
44 })
45
46 t.Run("create namespace should work", func(t *testing.T) {
47 etcdStore := mem.NewStore()
48
49 _, err := etcdStore.Set(utils.NamespaceListKey(), &pb.EntityList{
50 Entities: []*pb.EntityName{
51 {
52 Name: "ns1",
53 },
54 },
55 })
56 assert.NoError(t, err)
57
58 // test
59 namespaceMutator := NewNamespaceMutator(etcdStore)
60 err = namespaceMutator.CreateNamespace("ns1")
61 assert.EqualError(t, err, common.ErrNamespaceAlreadyExists.Error())
62
63 err = namespaceMutator.CreateNamespace("ns2")
64 assert.NoError(t, err)
65
66 _, err = etcdStore.Get(utils.JobListKey("ns2"))
67 assert.NoError(t, err)
68 _, err = etcdStore.Get(utils.SchemaListKey("ns2"))
69 assert.NoError(t, err)
70 })
71}

Callers

nothing calls this directly

Calls 10

ListNamespacesMethod · 0.95
CreateNamespaceMethod · 0.95
NamespaceListKeyFunction · 0.92
JobListKeyFunction · 0.92
SchemaListKeyFunction · 0.92
NewNamespaceMutatorFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.65
GetMethod · 0.65
SetMethod · 0.45

Tested by

no test coverage detected