-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package batch | ||
|
||
import ( | ||
"testing" | ||
|
||
radixv1 "github.com/equinor/radix-operator/pkg/apis/radix/v1" | ||
) | ||
|
||
func Test_getJobImage(t *testing.T) { | ||
type args struct { | ||
jobComponentImage string | ||
imageTagName string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
}{ | ||
{name: "image without repo and tag, no imageTagName", args: args{jobComponentImage: "alpine", imageTagName: ""}, want: "alpine"}, | ||
{name: "image with repo, no tag, no imageTagName", args: args{jobComponentImage: "somerepo/alpine", imageTagName: ""}, want: "somerepo/alpine"}, | ||
{name: "image with repo, org, no tag, no imageTagName", args: args{jobComponentImage: "somerepo/org/alpine", imageTagName: ""}, want: "somerepo/org/alpine"}, | ||
{name: "image with repo and domain, org, no tag, no imageTagName", args: args{jobComponentImage: "somerepo.com/org/alpine", imageTagName: ""}, want: "somerepo/org/alpine"}, | ||
{name: "image without repo and tag, no imageTagName", args: args{jobComponentImage: "alpine", imageTagName: ""}, want: "alpine"}, | ||
{name: "image with repo and tag, no imageTagName", args: args{jobComponentImage: "somerepo/alpine", imageTagName: ""}, want: "somerepo/alpine"}, | ||
{name: "image with repo, org and tag, no imageTagName", args: args{jobComponentImage: "somerepo/org/alpine", imageTagName: ""}, want: "somerepo/org/alpine"}, | ||
{name: "image with repo and domain, org and tag, no imageTagName", args: args{jobComponentImage: "somerepo.com/org/alpine", imageTagName: ""}, want: "somerepo/org/alpine"}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
jobComponent := radixv1.RadixDeployJobComponent{Image: tt.args.jobComponentImage} | ||
radixBatch := radixv1.RadixBatchJob{ImageTagName: tt.args.imageTagName} | ||
if gotImage := getJobImage(&jobComponent, &radixBatch); gotImage != tt.want { | ||
t.Errorf("getJobImage() = %v, want %v", gotImage, tt.want) | ||
} | ||
}) | ||
} | ||
} |