@@ -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,27 @@ 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. %d plugins found: %s" ,
810+ len (plugins ),
811+ strings .Join (
812+ lo .Map (plugins , func (p * kong.Plugin , _ int ) string {
813+ return lo .FromPtrOr (p .Name , "_" )
814+ }),
815+ "," ),
816+ )
809817 return false
810818 }
811819
812- configJSON , err := json .Marshal (plugin .Config )
820+ configJSON , err := json .Marshal (datadogPlugin .Config )
813821 require .NoError (t , err )
814822 t .Logf ("Configuration of datadog plugin: %s" , string (configJSON ))
815823
816- configPrefix , ok := plugin .Config ["prefix" ]
824+ configPrefix , ok := datadogPlugin .Config ["prefix" ]
817825 return ok && configPrefix == nil
818826 }, ingressWait , waitTick , "failed to find 'datadog' plugin with null in config.prefix in Kong" )
819827}
0 commit comments