Skip to content

Commit

Permalink
test: Add UTs for invalid image source or destination (#359)
Browse files Browse the repository at this point in the history
**Reason for Change**:
Couple UTs added

**Requirements**

- [ x] added unit tests and e2e tests (if applicable).
  • Loading branch information
ishaansehgal99 authored Apr 25, 2024
1 parent aa89d20 commit 9342647
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions api/v1alpha1/workspace_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,22 @@ func TestDataSourceValidateCreate(t *testing.T) {
},
wantErr: false,
},
{
name: "Image without URL Specified",
dataSource: &DataSource{
Image: "data-image:latest",
ImagePullSecrets: []string{"imagePushSecret"},
},
wantErr: true,
},
{
name: "Image without Tag Specified",
dataSource: &DataSource{
Image: "aimodels.azurecr.io/data-image",
ImagePullSecrets: []string{"imagePushSecret"},
},
wantErr: true,
},
{
name: "None specified",
dataSource: &DataSource{},
Expand Down Expand Up @@ -1049,16 +1065,32 @@ func TestDataDestinationValidateCreate(t *testing.T) {
{
name: "Image specified only",
dataDestination: &DataDestination{
Image: "aimodels.azurecr.io/data-image:latest",
Image: "aimodels.azurecr.io/data-image:latest",
ImagePushSecret: "imagePushSecret",
},
wantErr: false,
},
{
name: "Image without URL Specified",
dataDestination: &DataDestination{
Image: "data-image:latest",
ImagePushSecret: "imagePushSecret",
},
wantErr: true,
},
{
name: "Image without Tag Specified",
dataDestination: &DataDestination{
Image: "aimodels.azurecr.io/data-image",
ImagePushSecret: "imagePushSecret",
},
wantErr: true,
},
{
name: "Both fields specified",
dataDestination: &DataDestination{
Volume: &v1.VolumeSource{},
Image: "aimodels.azurecr.io/data-image:latest",
Volume: &v1.VolumeSource{},
Image: "aimodels.azurecr.io/data-image:latest",
ImagePushSecret: "imagePushSecret",
},
wantErr: false,
Expand Down

0 comments on commit 9342647

Please sign in to comment.