Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
absolutelightning committed Sep 16, 2023
1 parent dc4f9d1 commit ecc8dbf
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions api/catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,49 @@ func TestAPI_CatalogServices_NodeMetaFilter(t *testing.T) {
})
}

func TestAPI_CatalogServices_NodeMetaFilterFix(t *testing.T) {
t.Parallel()
meta := map[string]string{"somekey": "somevalue"}
c, s := makeClientWithConfig(t, nil, func(conf *testutil.TestServerConfig) {
conf.NodeMeta = meta
conf.NodeName = "foobar"
})
defer s.Stop()

// Register service and proxy instances to test against.
service := &AgentService{
ID: "redis1",
Service: "redis",
Port: 8000,
Connect: &AgentServiceConnect{Native: true},
}

reg := &CatalogRegistration{
Datacenter: "dc1",
Node: "foobar",
Address: "192.168.10.10",
Service: service,
}

catalog := c.Catalog()
retry.Run(t, func(r *retry.R) {
if _, err := catalog.Register(reg, nil); err != nil {
r.Fatal(err)
}
services, meta, err := catalog.Services(&QueryOptions{NodeMeta: meta})
if err != nil {
r.Fatal(err)
}

if meta.LastIndex == 0 {
r.Fatalf("Bad: %v", meta)
}

if len(services) == 1 {
r.Fatalf("Bad: %v", services)
}
})
}
func TestAPI_CatalogService(t *testing.T) {
t.Parallel()
c, s := makeClient(t)
Expand Down

0 comments on commit ecc8dbf

Please sign in to comment.