diff --git a/test/e2e/source_list_test.go b/test/e2e/source_list_test.go index 7d82c62d6..3c6d248af 100644 --- a/test/e2e/source_list_test.go +++ b/test/e2e/source_list_test.go @@ -52,17 +52,55 @@ func TestSourceList(t *testing.T) { it, err := test.NewKnTest() assert.NilError(t, err) defer func() { + assert.NilError(t, tearDownForSourceAPIServer(t, it)) assert.NilError(t, it.Teardown()) }() r := test.NewKnRunResultCollector(t, it) + defer r.DumpIfFailed() + setupForSourceAPIServer(t, it) + test.ServiceCreate(r, "testsvc0") t.Log("List sources empty case") output := sourceList(r) assert.Check(t, util.ContainsAll(output, "No", "sources", "found", "namespace")) assert.Check(t, util.ContainsNone(output, "NAME", "TYPE", "RESOURCE", "SINK", "READY")) + t.Log("Create API Server") + apiServerSourceCreate(r, "testapisource0", "Event:v1:key1=value1", "testsa", "svc:testsvc0") + apiServerSourceListOutputName(r, "testapisource0") + + t.Log("Create source binding") + sourceBindingCreate(r, "my-binding0", "Deployment:apps/v1:myapp", "svc:testsvc0") + sourceBindingListOutputName(r, "my-binding0") + + t.Log("Create ping source") + pingSourceCreate(r, "testpingsource0", "* * * * */1", "ping", "svc:testsvc0") + pingSourceListOutputName(r, "testpingsource0") + + t.Log("List sources filter valid case") + output = sourceList(r, "--type", "PingSource") + assert.Check(t, util.ContainsAll(output, "NAME", "TYPE", "RESOURCE", "SINK", "READY")) + assert.Check(t, util.ContainsAll(output, "testpingsource0", "PingSource", "pingsources.sources.knative.dev", "svc:testsvc0")) + + t.Log("List sources filter invalid case") + output = sourceList(r, "--type", "testapisource0") + assert.Check(t, util.ContainsAll(output, "No", "sources", "found", "namespace")) + output = sourceList(r, "--type", "TestSource", "-oyaml") + assert.Check(t, util.ContainsAll(output, "No", "sources", "found", "namespace")) + + t.Log("List available source in YAML format") + output = sourceList(r, "--type", "PingSource,ApiServerSource", "-oyaml") + assert.Check(t, util.ContainsAll(output, "testpingsource0", "PingSource", "Service", "testsvc0")) + assert.Check(t, util.ContainsAll(output, "testapisource0", "ApiServerSource", "Service", "testsvc0")) + + t.Log("Delete apiserver sources") + apiServerSourceDelete(r, "testapisource0") + t.Log("Delete source binding") + sourceBindingDelete(r, "my-binding0") + t.Log("Delete Ping sources") + pingSourceDelete(r, "testpingsource0") // non empty list case is tested in test/e2e/source_apiserver_it.go where source setup is present }