Skip to content

Commit

Permalink
fixL move mapper to tcl
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io>
  • Loading branch information
vsukhin committed Oct 16, 2024
1 parent c3a077a commit 9dc607f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/mapper/cdevents/mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
cdevents "github.com/cdevents/sdk-go/pkg/api"

"github.com/kubeshop/testkube/pkg/api/v1/testkube"
"github.com/kubeshop/testkube/pkg/tcl/testworkflowstcl/mapper"
)

// MapTestkubeEventToCDEvent maps OpenAPI spec Event to CDEvent CDEventReader
Expand Down Expand Up @@ -526,7 +527,8 @@ func MapTestkubeEventQueuedTestWorkflowTestToCDEvent(event testkube.Event, clust
if event.TestWorkflowExecution.RunningContext != nil && event.TestWorkflowExecution.RunningContext.Actor != nil &&
event.TestWorkflowExecution.RunningContext.Actor.Type_ != nil {
ev.SetSubjectTrigger(&cdevents.TestCaseRunQueuedSubjectContentTrigger{
Type: MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType(*event.TestWorkflowExecution.RunningContext.Actor.Type_),
// Pro edition only (tcl protected code)
Type: mapper.MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType(*event.TestWorkflowExecution.RunningContext.Actor.Type_),
})
}
}
Expand Down Expand Up @@ -572,7 +574,8 @@ func MapTestkubeEventQueuedTestWorkflowTestSuiteToCDEvent(event testkube.Event,
if event.TestWorkflowExecution.RunningContext != nil && event.TestWorkflowExecution.RunningContext.Actor != nil &&
event.TestWorkflowExecution.RunningContext.Actor.Type_ != nil {
ev.SetSubjectTrigger(&cdevents.TestSuiteRunQueuedSubjectContentTrigger{
Type: MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType(*event.TestWorkflowExecution.RunningContext.Actor.Type_),
// Pro edition only (tcl protected code)
Type: mapper.MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType(*event.TestWorkflowExecution.RunningContext.Actor.Type_),
})
}
}
Expand Down Expand Up @@ -619,7 +622,8 @@ func MapTestkubeEventStartTestWorkflowTestToCDEvent(event testkube.Event, cluste
if event.TestWorkflowExecution.RunningContext != nil && event.TestWorkflowExecution.RunningContext.Actor != nil &&
event.TestWorkflowExecution.RunningContext.Actor.Type_ != nil {
ev.SetSubjectTrigger(&cdevents.TestCaseRunStartedSubjectContentTrigger{
Type: MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType(*event.TestWorkflowExecution.RunningContext.Actor.Type_),
// Pro edition only (tcl protected code)
Type: mapper.MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType(*event.TestWorkflowExecution.RunningContext.Actor.Type_),
})
}
}
Expand Down Expand Up @@ -665,7 +669,8 @@ func MapTestkubeEventStartTestWorkflowTestSuiteToCDEvent(event testkube.Event, c
if event.TestWorkflowExecution.RunningContext != nil && event.TestWorkflowExecution.RunningContext.Actor != nil &&
event.TestWorkflowExecution.RunningContext.Actor.Type_ != nil {
ev.SetSubjectTrigger(&cdevents.TestSuiteRunStartedSubjectContentTrigger{
Type: MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType(*event.TestWorkflowExecution.RunningContext.Actor.Type_),
// Pro edition only (tcl protected code)
Type: mapper.MapTestkubeTestWorkflowRunningContextActorToCDEventTiggerType(*event.TestWorkflowExecution.RunningContext.Actor.Type_),
})
}
}
Expand Down
14 changes: 14 additions & 0 deletions pkg/tcl/testworkflowstcl/mapper/cdevents_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package mapper

import (
"github.com/kubeshop/testkube/internal/common"
"github.com/kubeshop/testkube/pkg/api/v1/testkube"
)

func NewMockRunningContext() *testkube.TestWorkflowRunningContext {
return &testkube.TestWorkflowRunningContext{
Actor: &testkube.TestWorkflowRunningContextActor{
Type_: common.Ptr(testkube.CRON_TestWorkflowRunningContextActorType),
},
}
}

0 comments on commit 9dc607f

Please sign in to comment.