Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiaoliang committed Feb 6, 2020
1 parent 8f9b25d commit b8da8b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
24 changes: 12 additions & 12 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ func TestClient_Put(t *testing.T) {
Labels: map[string]string{"service": "client"},
Value: "timeout: 1s",
}
_, err := c.Put(context.TODO(), kv, WithProject("test"))
_, err := c.Put(context.TODO(), kv, WithProject("client_test"))
assert.NoError(t, err)

kvs, _ := c.Get(context.TODO(),
WithKey("app.properties"),
WithGetProject("test"),
WithGetProject("client_test"),
WithLabels(map[string]string{"service": "client"}))
assert.GreaterOrEqual(t, len(kvs.Data), 1)

_, err = c.Get(context.TODO(),
WithGetProject("test"),
WithGetProject("client_test"),
WithLabels(map[string]string{"service": "client"}))
assert.Equal(t, ErrNoChanges, err)

Expand All @@ -59,7 +59,7 @@ func TestClient_Put(t *testing.T) {
go func() {
kvs, err = c.Get(context.TODO(),
WithLabels(map[string]string{"service": "client"}),
WithGetProject("test"),
WithGetProject("client_test"),
WithWait("10s"))
assert.NoError(t, err)
assert.Equal(t, "timeout: 2s", kvs.Data[0].Value)
Expand All @@ -69,7 +69,7 @@ func TestClient_Put(t *testing.T) {
Labels: map[string]string{"service": "client"},
Value: "timeout: 2s",
}
_, err := c.Put(context.TODO(), kv, WithProject("test"))
_, err := c.Put(context.TODO(), kv, WithProject("client_test"))
assert.NoError(t, err)
})
t.Run("exact match", func(t *testing.T) {
Expand All @@ -78,10 +78,10 @@ func TestClient_Put(t *testing.T) {
Labels: map[string]string{"service": "client", "version": "1.0"},
Value: "timeout: 2s",
}
_, err := c.Put(context.TODO(), kv, WithProject("test"))
_, err := c.Put(context.TODO(), kv, WithProject("client_test"))
assert.NoError(t, err)
kvs, err = c.Get(context.TODO(),
WithGetProject("test"),
WithGetProject("client_test"),
WithLabels(map[string]string{"service": "client"}),
WithExact())
assert.NoError(t, err)
Expand All @@ -99,15 +99,15 @@ func TestClient_Delete(t *testing.T) {
kvBody.Value = "100s"
kvBody.ValueType = "text"
kvBody.Labels = make(map[string]string)
kvBody.Labels["env"] = "test"
kv, err := c.Put(context.TODO(), kvBody, WithProject("test"))
kvBody.Labels["env"] = "client_test"
kv, err := c.Put(context.TODO(), kvBody, WithProject("client_test"))
assert.NoError(t, err)
kvs, err := c.Get(context.TODO(),
WithKey("time"),
WithGetProject("test"),
WithLabels(map[string]string{"env": "test"}))
WithGetProject("client_test"),
WithLabels(map[string]string{"env": "client_test"}))
assert.NoError(t, err)
assert.NotNil(t, kvs)
err = c.Delete(context.TODO(), kv.ID, "", WithProject("test"))
err = c.Delete(context.TODO(), kv.ID, "", WithProject("client_test"))
assert.NoError(t, err)
}
1 change: 1 addition & 0 deletions server/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
KVService KV
HistoryService History
RevisionService Revision
LabelService Label
DBInit Init
)

Expand Down

0 comments on commit b8da8b6

Please sign in to comment.