Skip to content

Commit

Permalink
fix: unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 committed Jul 25, 2024
1 parent 36f496a commit 317ef62
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ func TestProcess_IgnoreExecutionOfStaticSkipGroup(t *testing.T) {
// Build the expectations
want := actiontypes.NewActionList().
// Configure
Setup(true, true).
Setup(false, false). // don't copy as there is nothing to do

// Declare stage conditions
Declare("init", "false").
Expand Down Expand Up @@ -557,7 +557,7 @@ func TestProcess_IgnoreExecutionOfStaticSkipGroup_Pause(t *testing.T) {
// Build the expectations
want := actiontypes.NewActionList().
// Configure
Setup(true, true).
Setup(false, false). // don't copy as there is nothing to do

// Declare stage conditions
Declare("init", "false").
Expand Down
11 changes: 8 additions & 3 deletions pkg/testworkflows/testworkflowprocessor/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/client-go/kubernetes"

"github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor/action/actiontypes"
"github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor/action/actiontypes/lite"
"github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor/constants"
"github.com/kubeshop/testkube/pkg/testworkflows/testworkflowprocessor/stage"
)
Expand All @@ -22,10 +23,14 @@ type Bundle struct {
Signature []stage.Signature
}

func (b *Bundle) Actions() actiontypes.ActionGroups {
var actions actiontypes.ActionGroups
func (b *Bundle) Actions() (actions actiontypes.ActionGroups) {
_ = json.Unmarshal([]byte(b.Job.Spec.Template.Annotations[constants.SpecAnnotationName]), &actions)
return actions
return
}

func (b *Bundle) LiteActions() (actions lite.LiteActionGroups) {
_ = json.Unmarshal([]byte(b.Job.Spec.Template.Annotations[constants.SpecAnnotationName]), &actions)
return
}

func (b *Bundle) Deploy(ctx context.Context, clientSet kubernetes.Interface, namespace string) (err error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func TestProcessBasic(t *testing.T) {
wantActions := actiontypes.NewActionGroups().
Append(func(list actiontypes.ActionList) actiontypes.ActionList {
return list.
Setup(true, true).
Setup(false, false).
Declare(constants.RootOperationName, "true").
Declare(sig[0].Ref(), "true", constants.RootOperationName).
Result(constants.RootOperationName, sig[0].Ref()).
Expand Down Expand Up @@ -385,7 +385,7 @@ func TestProcessBasicEnvReference(t *testing.T) {
wantActions := lite.NewLiteActionGroups().
Append(func(list lite.LiteActionList) lite.LiteActionList {
return list.
Setup(true, true).
Setup(false, false).
Declare(constants.RootOperationName, "true").
Declare(sig[0].Ref(), "true", constants.RootOperationName).
Result(constants.RootOperationName, sig[0].Ref()).
Expand Down Expand Up @@ -458,7 +458,7 @@ func TestProcessBasicEnvReference(t *testing.T) {

assert.NoError(t, err)
assert.Equal(t, wantPod, res.Job.Spec.Template.Spec)
assert.Equal(t, wantActions, res.Actions())
assert.Equal(t, wantActions, res.LiteActions())
}

func TestProcessMultipleSteps(t *testing.T) {
Expand All @@ -480,7 +480,7 @@ func TestProcessMultipleSteps(t *testing.T) {
wantActions := lite.NewLiteActionGroups().
Append(func(list lite.LiteActionList) lite.LiteActionList {
return list.
Setup(true, true).
Setup(false, false).
Declare(constants.RootOperationName, "true").
Declare(sig[0].Ref(), "true", constants.RootOperationName).
Declare(sig[1].Ref(), sig[0].Ref(), constants.RootOperationName).
Expand Down Expand Up @@ -573,7 +573,7 @@ func TestProcessMultipleSteps(t *testing.T) {

assert.NoError(t, err)
assert.Equal(t, want, res.Job.Spec.Template.Spec)
assert.Equal(t, wantActions, res.Actions())
assert.Equal(t, wantActions, res.LiteActions())
}

func TestProcessNestedSteps(t *testing.T) {
Expand Down Expand Up @@ -602,7 +602,7 @@ func TestProcessNestedSteps(t *testing.T) {
wantActions := lite.NewLiteActionGroups().
Append(func(list lite.LiteActionList) lite.LiteActionList {
return list.
Setup(true, true).
Setup(false, false).
Declare(constants.RootOperationName, "true").
Declare(sig[0].Ref(), "true", constants.RootOperationName).
Declare(sig[1].Ref(), sig[0].Ref(), constants.RootOperationName).
Expand Down Expand Up @@ -749,7 +749,7 @@ func TestProcessNestedSteps(t *testing.T) {
}

assert.NoError(t, err)
assert.Equal(t, wantActions, res.Actions())
assert.Equal(t, wantActions, res.LiteActions())
assert.Equal(t, want, res.Job.Spec.Template.Spec)
}

Expand Down Expand Up @@ -971,7 +971,7 @@ func TestProcessShell(t *testing.T) {
want := lite.NewLiteActionGroups().
Append(func(list lite.LiteActionList) lite.LiteActionList {
return list.
Setup(true, true).
Setup(false, false).
Declare(constants.RootOperationName, "true").
Declare(sig[0].Ref(), "true", constants.RootOperationName).
Result(constants.RootOperationName, sig[0].Ref()).
Expand All @@ -995,5 +995,5 @@ func TestProcessShell(t *testing.T) {
})

assert.NoError(t, err)
assert.Equal(t, want, res.Actions())
assert.Equal(t, want, res.LiteActions())
}

0 comments on commit 317ef62

Please sign in to comment.