Skip to content

Commit

Permalink
fix: map test suite YAML to proper update structure (#4129)
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 committed Jul 5, 2023
1 parent e745002 commit 385c888
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/mapper/testsuites/kube_openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ func MapTestSuiteTestCRDToUpdateRequest(testSuite *testsuitesv3.TestSuite) (requ
request.Before = &before

steps := mapCRDToTestBatchSteps(testSuite.Spec.Steps)
request.Before = &steps
request.Steps = &steps

after := mapCRDToTestBatchSteps(testSuite.Spec.After)
request.Before = &after
request.After = &after

request.Labels = &testSuite.Labels

Expand Down
55 changes: 53 additions & 2 deletions pkg/mapper/testsuites/kube_openapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestMapTestSuiteListKubeToAPI(t *testing.T) {
{
Execute: []testsuitesv3.TestSuiteStepSpec{
{
Delay: metav1.Duration{Duration: time.Second},
Delay: metav1.Duration{Duration: 2 * time.Second},
},
},
},
Expand Down Expand Up @@ -50,7 +50,58 @@ func TestMapTestSuiteListKubeToAPI(t *testing.T) {
},
)

assert.Equal(t, 1, len(openAPITest.Steps))
assert.Equal(t, 1, len(openAPITest.Before))
assert.Equal(t, "2s", openAPITest.Before[0].Execute[0].Delay)
assert.Equal(t, 1, len(openAPITest.Steps))
assert.Equal(t, "some-test-name", openAPITest.Steps[0].Execute[0].Test)
assert.Equal(t, 1, len(openAPITest.After))
assert.Equal(t, "1s", openAPITest.After[0].Execute[0].Delay)
}

func TestMapTestSuiteTestCRDToUpdateRequest(t *testing.T) {

openAPITest := MapTestSuiteTestCRDToUpdateRequest(
&testsuitesv3.TestSuite{
Spec: testsuitesv3.TestSuiteSpec{
Before: []testsuitesv3.TestSuiteBatchStep{
{
Execute: []testsuitesv3.TestSuiteStepSpec{
{
Delay: metav1.Duration{Duration: 2 * time.Second},
},
},
},
},

Steps: []testsuitesv3.TestSuiteBatchStep{
{
Execute: []testsuitesv3.TestSuiteStepSpec{
{
Test: "some-test-name",
},
},
},
},

After: []testsuitesv3.TestSuiteBatchStep{
{
Execute: []testsuitesv3.TestSuiteStepSpec{
{
Delay: metav1.Duration{Duration: time.Second},
},
},
},
},

Repeats: 2,
},
},
)

assert.Equal(t, 1, len(*openAPITest.Before))
assert.Equal(t, "2s", (*openAPITest.Before)[0].Execute[0].Delay)
assert.Equal(t, 1, len(*openAPITest.Steps))
assert.Equal(t, "some-test-name", (*openAPITest.Steps)[0].Execute[0].Test)
assert.Equal(t, 1, len(*openAPITest.After))
assert.Equal(t, "1s", (*openAPITest.After)[0].Execute[0].Delay)
}

0 comments on commit 385c888

Please sign in to comment.