Skip to content

Commit

Permalink
test: ensure the correct EnvoyFilter is kept
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <[email protected]>
  • Loading branch information
spacewander committed Sep 12, 2024
1 parent 82b6aa8 commit a46adae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
1 change: 1 addition & 0 deletions controller/registries/nacos/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func NewClient(config *nacos.Config) (*NacosClient, error) {
),
}

fmt.Printf("AA %+v %+v\n", cc, sc)
namingClient, err := clients.NewNamingClient(vo.NacosClientParam{
ClientConfig: cc,
ServerConfigs: sc,
Expand Down
27 changes: 14 additions & 13 deletions controller/registries/nacos/v1/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ import (

func TestNewClient(t *testing.T) {
config := &nacos.Config{
ServerUrl: "http://127.0.0.1:9999999",
}
_, err := NewClient(config)
assert.ErrorContains(t, err, "can not create naming client")

config = &nacos.Config{
ServerUrl: "::::::::::::",
}

_, err = NewClient(config)
assert.ErrorContains(t, err, "invalid server url")

config = &nacos.Config{
ServerUrl: "http://127.0.0.1:8848",
Version: "v1",
}
Expand All @@ -43,20 +56,8 @@ func TestNewClient(t *testing.T) {
patches.ApplyFunc(clients.NewNamingClient, func(param vo.NacosClientParam) (naming_client.INamingClient, error) {
return nil, nil
})
_, err := NewClient(config)
_, err = NewClient(config)
assert.Nil(t, err)

patches.Reset()

config = &nacos.Config{}
_, err = NewClient(config)
assert.Error(t, err)

config = &nacos.Config{
ServerUrl: "::::::::::::",
}

_, err = NewClient(config)
assert.Error(t, err)

}
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,14 @@ var _ = Describe("Consumer controller", func() {
return false
}
for _, item := range envoyfilters.Items {
if item.Name == "htnn-consumer" {
if item.Name == "htnn-consumer" && item.Namespace == "istio-system" {
ef = item
return true
}
}
return false
}, timeout, interval).Should(BeTrue())

Expect(ef.Namespace).To(Equal("istio-system"))
Expect(len(ef.Spec.ConfigPatches)).To(Equal(2))
cp := ef.Spec.ConfigPatches[0]
Expect(cp.ApplyTo).To(Equal(istioapi.EnvoyFilter_EXTENSION_CONFIG))
Expand Down

0 comments on commit a46adae

Please sign in to comment.