Skip to content

Commit

Permalink
test SubscribeToNamesapce
Browse files Browse the repository at this point in the history
  • Loading branch information
philchia committed Feb 27, 2019
1 parent 9bd9293 commit f6a01bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 16 additions & 0 deletions agollo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,20 @@ func TestAgolloStart(t *testing.T) {
if val != `{"name":"agollo"}` {
t.Errorf(`GetStringValue of client.json content should = {"name":"agollo"}, got %v`, val)
}

if err := SubscribeToNamesapce("new_namespace.json"); err != nil {
t.Error(err)
}

mockserver.Set("new_namespace.json", "key", "1")
select {
case <-updates:
case <-time.After(time.Millisecond * 30000):
}

val = GetStringValueWithNameSpace("new_namespace.json", "key", "defaultValue")
if val != `1` {
t.Errorf(`GetStringValueWithNameSpace of new_namespace.json content should = 1, got %v`, val)
}

}
1 change: 0 additions & 1 deletion poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func (p *longPoller) addNamespaces(namespaces ...string) error {
}

func (p *longPoller) watchUpdates() {

p.ctx, p.cancel = context.WithCancel(context.Background())
defer p.cancel()

Expand Down

0 comments on commit f6a01bf

Please sign in to comment.