@@ -16,6 +16,7 @@ import (
1616 "github.com/kong/go-kong/kong"
1717 "github.com/kong/kubernetes-testing-framework/pkg/clusters"
1818 "github.com/kong/kubernetes-testing-framework/pkg/utils/kubernetes/generators"
19+ "github.com/samber/lo"
1920 "github.com/stretchr/testify/assert"
2021 "github.com/stretchr/testify/require"
2122 corev1 "k8s.io/api/core/v1"
@@ -800,20 +801,26 @@ func TestPluginNullInConfig(t *testing.T) {
800801 require .NoError (t , err , "failed to create Kong client" )
801802 plugins , err := kc .Plugins .ListAll (ctx )
802803 require .NoError (t , err , "failed to list plugins" )
803- if len (plugins ) != 1 {
804- t .Logf ("Expected to get 1 plugin, actual %d" , len (plugins ))
805- return false
806- }
807- plugin := plugins [0 ]
808- if plugin .Name == nil || * plugin .Name != "datadog" {
804+
805+ datadogPlugin , found := lo .Find (plugins , func (p * kong.Plugin ) bool {
806+ return p .Name != nil && * p .Name == "datadog"
807+ })
808+ if ! found {
809+ t .Logf ("datadog plugin not found. Plugins found: %s" ,
810+ strings .Join (
811+ lo .Map (plugins , func (p * kong.Plugin , _ int ) string {
812+ return lo .FromPtrOr (p .Name , "_" )
813+ }),
814+ "," ),
815+ )
809816 return false
810817 }
811818
812- configJSON , err := json .Marshal (plugin .Config )
819+ configJSON , err := json .Marshal (datadogPlugin .Config )
813820 require .NoError (t , err )
814821 t .Logf ("Configuration of datadog plugin: %s" , string (configJSON ))
815822
816- configPrefix , ok := plugin .Config ["prefix" ]
823+ configPrefix , ok := datadogPlugin .Config ["prefix" ]
817824 return ok && configPrefix == nil
818825 }, ingressWait , waitTick , "failed to find 'datadog' plugin with null in config.prefix in Kong" )
819826}
0 commit comments