Skip to content

Commit

Permalink
Fix flaky test Test_Handler_WorkflowMinimalAndPropsAndSpecAndGeneric
Browse files Browse the repository at this point in the history
Signed-off-by: Jordi Gil <[email protected]>
  • Loading branch information
jordigilh committed Jan 26, 2024
1 parent f23558c commit 1ed9a32
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions workflowproj/workflowproj_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (

"github.com/apache/incubator-kie-kogito-serverless-operator/api/metadata"
"github.com/stretchr/testify/assert"
corev1 "k8s.io/api/core/v1"
"k8s.io/client-go/kubernetes/scheme"
)

Expand Down Expand Up @@ -112,8 +113,21 @@ func Test_Handler_WorkflowMinimalAndPropsAndSpecAndGeneric(t *testing.T) {
assert.Equal(t, "02-hello-resources", proj.Resources[1].Name)
assert.Equal(t, proj.Workflow.Spec.Resources.ConfigMaps[0].ConfigMap.Name, proj.Resources[0].Name)
assert.Equal(t, proj.Workflow.Spec.Resources.ConfigMaps[1].ConfigMap.Name, proj.Resources[1].Name)
assert.NotEmpty(t, proj.Resources[0].Data["myopenapi.json"], fmt.Sprintf("Data in proj.Resources[0] is empty %+v", proj.Resources[0]))
assert.NotEmpty(t, proj.Resources[1].Data["input.json"], fmt.Sprintf("Data in proj.Resources[1] is empty %+v", proj.Resources[1]))
data, err := getResourceDataWithFileName(proj.Resources, "myopenapi.json")
assert.NoError(t, err)
assert.NotEmpty(t, data)
data, err = getResourceDataWithFileName(proj.Resources, "input.json")
assert.NoError(t, err)
assert.NotEmpty(t, data)
}

func getResourceDataWithFileName(cms []*corev1.ConfigMap, fileName string) (string, error) {
for i := range cms {
if data, ok := cms[i].Data[fileName]; ok {
return data, nil
}
}
return "", fmt.Errorf("No configmap found with data containing filename %s", fileName)
}

func Test_Handler_WorklflowServiceAndPropsAndSpec_SaveAs(t *testing.T) {
Expand Down

0 comments on commit 1ed9a32

Please sign in to comment.