Skip to content

Commit

Permalink
Only compare ImageID suffix in TestTaskRunStatus test
Browse files Browse the repository at this point in the history
On some systems (i.e: OpenShift) we are getting a different prefix than
docker-pullable:// as docker.io/library instead,

Let's ignore that prefix and only compare the suffix of the fqImageName

Signed-off-by: Chmouel Boudjnah <[email protected]>
  • Loading branch information
chmouel committed Aug 22, 2019
1 parent b810085 commit 306ccac
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions test/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
package test

import (
"strings"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -152,11 +153,15 @@ func TestTaskRunStatus(t *testing.T) {
},
Name: "hello",
ContainerName: "step-hello",
ImageID: "docker-pullable://" + fqImageName,
}}

ignoreTerminatedFields := cmpopts.IgnoreFields(corev1.ContainerStateTerminated{}, "StartedAt", "FinishedAt", "ContainerID")
if d := cmp.Diff(taskrun.Status.Steps, expectedStepState, ignoreTerminatedFields); d != "" {
ignoreStepFields := cmpopts.IgnoreFields(v1alpha1.StepState{}, "ImageID")
if d := cmp.Diff(taskrun.Status.Steps, expectedStepState, ignoreTerminatedFields, ignoreStepFields); d != "" {
t.Fatalf("-got, +want: %v", d)
}
// Note(chmouel): Sometime we have docker-pullable:// or docker.io/library as suffix, so let only compare the suffix
if !strings.HasSuffix(taskrun.Status.Steps[0].ImageID, fqImageName) {
t.Fatalf("`ImageID: %s` does not end with `%s`", taskrun.Status.Steps[0].ImageID, fqImageName)
}
}

0 comments on commit 306ccac

Please sign in to comment.