diff --git a/pkg/event/kind/cdevent/listener_test.go b/pkg/event/kind/cdevent/listener_test.go index e86fff40079..448bf6ab402 100644 --- a/pkg/event/kind/cdevent/listener_test.go +++ b/pkg/event/kind/cdevent/listener_test.go @@ -93,6 +93,7 @@ func TestCDEventListener_Notify(t *testing.T) { func exampleExecution() *testkube.Execution { execution := testkube.NewQueuedExecution() + execution.Id = "1" execution.Name = "test-1" execution.TestName = "test" execution.TestNamespace = "testkube" diff --git a/pkg/mapper/cdevents/mapper.go b/pkg/mapper/cdevents/mapper.go index 1245a9d3197..e6e3aa50843 100644 --- a/pkg/mapper/cdevents/mapper.go +++ b/pkg/mapper/cdevents/mapper.go @@ -40,7 +40,7 @@ func MapTestkubeEventQueuedTestToCDEvent(event testkube.Event, clusterID, defaul } if event.TestExecution != nil { - ev.SetSubjectId(event.TestExecution.Name) + ev.SetSubjectId(event.TestExecution.Id) } ev.SetSubjectSource(clusterID) @@ -49,7 +49,7 @@ func MapTestkubeEventQueuedTestToCDEvent(event testkube.Event, clusterID, defaul ev.SetSubjectTestCase(&cdevents.TestCaseRunQueuedSubjectContentTestCase{ Id: event.TestExecution.TestName, Type: MapTestkubeTestTypeToCDEventTestCaseType(event.TestExecution.TestType), - Uri: fmt.Sprintf("%s/tests/executions/%s", dashboardURI, event.TestExecution.TestName), + Uri: fmt.Sprintf("%s/tests/%s", dashboardURI, event.TestExecution.TestName), }) namespace := event.TestExecution.TestNamespace @@ -88,7 +88,7 @@ func MapTestkubeEventStartTestToCDEvent(event testkube.Event, clusterID, default } if event.TestExecution != nil { - ev.SetSubjectId(event.TestExecution.Name) + ev.SetSubjectId(event.TestExecution.Id) } ev.SetSubjectSource(clusterID) @@ -97,7 +97,7 @@ func MapTestkubeEventStartTestToCDEvent(event testkube.Event, clusterID, default ev.SetSubjectTestCase(&cdevents.TestCaseRunStartedSubjectContentTestCase{ Id: event.TestExecution.TestName, Type: MapTestkubeTestTypeToCDEventTestCaseType(event.TestExecution.TestType), - Uri: fmt.Sprintf("%s/tests/executions/%s", dashboardURI, event.TestExecution.TestName), + Uri: fmt.Sprintf("%s/tests/%s", dashboardURI, event.TestExecution.TestName), }) namespace := event.TestExecution.TestNamespace @@ -136,7 +136,7 @@ func MapTestkubeEventFinishTestToCDEvent(event testkube.Event, clusterID, defaul } if event.TestExecution != nil { - ev.SetSubjectId(event.TestExecution.Name) + ev.SetSubjectId(event.TestExecution.Id) } ev.SetSubjectSource(clusterID) @@ -145,7 +145,7 @@ func MapTestkubeEventFinishTestToCDEvent(event testkube.Event, clusterID, defaul ev.SetSubjectTestCase(&cdevents.TestCaseRunFinishedSubjectContentTestCase{ Id: event.TestExecution.TestName, Type: MapTestkubeTestTypeToCDEventTestCaseType(event.TestExecution.TestType), - Uri: fmt.Sprintf("%s/tests/executions/%s", dashboardURI, event.TestExecution.TestName), + Uri: fmt.Sprintf("%s/tests/%s", dashboardURI, event.TestExecution.TestName), }) namespace := event.TestExecution.TestNamespace @@ -219,7 +219,7 @@ func MapTestkubeEventQueuedTestSuiteToCDEvent(event testkube.Event, clusterID, d } if event.TestSuiteExecution != nil { - ev.SetSubjectId(event.TestSuiteExecution.Name) + ev.SetSubjectId(event.TestSuiteExecution.Id) } ev.SetSubjectSource(clusterID) @@ -256,7 +256,7 @@ func MapTestkubeEventStartTestSuiteToCDEvent(event testkube.Event, clusterID, da } if event.TestSuiteExecution != nil { - ev.SetSubjectId(event.TestSuiteExecution.Name) + ev.SetSubjectId(event.TestSuiteExecution.Id) } ev.SetSubjectSource(clusterID) @@ -265,7 +265,7 @@ func MapTestkubeEventStartTestSuiteToCDEvent(event testkube.Event, clusterID, da if event.TestSuiteExecution.TestSuite != nil { ev.SetSubjectTestSuite(&cdevents.TestSuiteRunStartedSubjectContentTestSuite{ Id: event.TestSuiteExecution.TestSuite.Name, - Uri: fmt.Sprintf("%s/test-suites/executions/%s", dashboardURI, event.TestSuiteExecution.TestSuite.Name), + Uri: fmt.Sprintf("%s/test-suites/%s", dashboardURI, event.TestSuiteExecution.TestSuite.Name), }) ev.SetSubjectEnvironment(&cdevents.Reference{ @@ -293,7 +293,7 @@ func MapTestkubeEventFinishTestSuiteToCDEvent(event testkube.Event, clusterID, d } if event.TestSuiteExecution != nil { - ev.SetSubjectId(event.TestSuiteExecution.Name) + ev.SetSubjectId(event.TestSuiteExecution.Id) } ev.SetSubjectSource(clusterID) @@ -302,7 +302,7 @@ func MapTestkubeEventFinishTestSuiteToCDEvent(event testkube.Event, clusterID, d if event.TestSuiteExecution.TestSuite != nil { ev.SetSubjectTestSuite(&cdevents.TestSuiteRunFinishedSubjectContentTestSuite{ Id: event.TestSuiteExecution.TestSuite.Name, - Uri: fmt.Sprintf("%s/test-suites/executions/%s", dashboardURI, event.TestSuiteExecution.TestSuite.Name), + Uri: fmt.Sprintf("%s/test-suites/%s", dashboardURI, event.TestSuiteExecution.TestSuite.Name), }) ev.SetSubjectEnvironment(&cdevents.Reference{ diff --git a/pkg/mapper/cdevents/mapper_test.go b/pkg/mapper/cdevents/mapper_test.go index 31ede996876..ad567e3e483 100644 --- a/pkg/mapper/cdevents/mapper_test.go +++ b/pkg/mapper/cdevents/mapper_test.go @@ -15,6 +15,7 @@ func TestMapTestkubeEventQueuedTestToCDEvent(t *testing.T) { event := testkube.Event{ TestExecution: &testkube.Execution{ + Id: "1", Name: "test-1", TestName: "Test 1", TestType: "ginkgo/test", @@ -35,7 +36,7 @@ func TestMapTestkubeEventQueuedTestToCDEvent(t *testing.T) { } subjectID := ev.GetSubjectId() - if subjectID != "test-1" { + if subjectID != "1" { t.Errorf("Unexpected subject ID: %s", subjectID) } @@ -63,7 +64,7 @@ func TestMapTestkubeEventQueuedTestToCDEvent(t *testing.T) { } testURI := cde.Subject.Content.TestCase.Uri - if testURI != "/tests/executions/Test 1" { + if testURI != "/tests/Test 1" { t.Errorf("Unexpected test case uri: %s", testURI) } @@ -98,6 +99,7 @@ func TestMapTestkubeEventStatTestToCDEvent(t *testing.T) { event := testkube.Event{ TestExecution: &testkube.Execution{ + Id: "1", Name: "test-1", TestName: "Test 1", TestType: "ginkgo/test", @@ -118,7 +120,7 @@ func TestMapTestkubeEventStatTestToCDEvent(t *testing.T) { } subjectID := ev.GetSubjectId() - if subjectID != "test-1" { + if subjectID != "1" { t.Errorf("Unexpected subject ID: %s", subjectID) } @@ -146,7 +148,7 @@ func TestMapTestkubeEventStatTestToCDEvent(t *testing.T) { } testURI := cde.Subject.Content.TestCase.Uri - if testURI != "/tests/executions/Test 1" { + if testURI != "/tests/Test 1" { t.Errorf("Unexpected test case uri: %s", testURI) } @@ -182,6 +184,7 @@ func TestMapTestkubeEventFinishTestToCDEvent(t *testing.T) { result := testkube.NewErrorExecutionResult(errors.New("fake")) event := testkube.Event{ TestExecution: &testkube.Execution{ + Id: "1", Name: "test-1", TestName: "Test 1", TestType: "ginkgo/test", @@ -203,7 +206,7 @@ func TestMapTestkubeEventFinishTestToCDEvent(t *testing.T) { } subjectID := ev.GetSubjectId() - if subjectID != "test-1" { + if subjectID != "1" { t.Errorf("Unexpected subject ID: %s", subjectID) } @@ -231,7 +234,7 @@ func TestMapTestkubeEventFinishTestToCDEvent(t *testing.T) { } testURI := cde.Subject.Content.TestCase.Uri - if testURI != "/tests/executions/Test 1" { + if testURI != "/tests/Test 1" { t.Errorf("Unexpected test case uri: %s", testURI) } @@ -271,6 +274,7 @@ func TestMapTestkubeEventQueuedTestSuiteToCDEvent(t *testing.T) { event := testkube.Event{ TestSuiteExecution: &testkube.TestSuiteExecution{ + Id: "1", Name: "suite-1", TestSuite: &testkube.ObjectRef{ Namespace: "default", @@ -290,7 +294,7 @@ func TestMapTestkubeEventQueuedTestSuiteToCDEvent(t *testing.T) { } subjectID := ev.GetSubjectId() - if subjectID != "suite-1" { + if subjectID != "1" { t.Errorf("Unexpected subject ID: %s", subjectID) } @@ -338,6 +342,7 @@ func TestMapTestkubeEventStartTestSuiteToCDEvent(t *testing.T) { event := testkube.Event{ TestSuiteExecution: &testkube.TestSuiteExecution{ + Id: "1", Name: "suite-1", TestSuite: &testkube.ObjectRef{ Namespace: "default", @@ -357,7 +362,7 @@ func TestMapTestkubeEventStartTestSuiteToCDEvent(t *testing.T) { } subjectID := ev.GetSubjectId() - if subjectID != "suite-1" { + if subjectID != "1" { t.Errorf("Unexpected subject ID: %s", subjectID) } @@ -380,7 +385,7 @@ func TestMapTestkubeEventStartTestSuiteToCDEvent(t *testing.T) { } suiteURI := cde.Subject.Content.TestSuite.Uri - if suiteURI != "/test-suites/executions/Suite 1" { + if suiteURI != "/test-suites/Suite 1" { t.Errorf("Unexpected test case uri: %s", suiteURI) } @@ -406,6 +411,7 @@ func TestMapTestkubeEventFinishTestSuiteToCDEvent(t *testing.T) { execution := testkube.NewFailedExecution(errors.New("fake")) event := testkube.Event{ TestSuiteExecution: &testkube.TestSuiteExecution{ + Id: "1", Name: "suite-1", TestSuite: &testkube.ObjectRef{ Namespace: "default", @@ -435,7 +441,7 @@ func TestMapTestkubeEventFinishTestSuiteToCDEvent(t *testing.T) { } subjectID := ev.GetSubjectId() - if subjectID != "suite-1" { + if subjectID != "1" { t.Errorf("Unexpected subject ID: %s", subjectID) } @@ -458,7 +464,7 @@ func TestMapTestkubeEventFinishTestSuiteToCDEvent(t *testing.T) { } suiteURI := cde.Subject.Content.TestSuite.Uri - if suiteURI != "/test-suites/executions/Suite 1" { + if suiteURI != "/test-suites/Suite 1" { t.Errorf("Unexpected test case uri: %s", suiteURI) }