-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ImageRunner: Add support for workflow type (#744)
* Add support for workflow type
- Loading branch information
Showing
10 changed files
with
227 additions
and
15 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
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
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
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
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
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
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,102 @@ | ||
package imagerunner | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/saucelabs/saucectl/internal/config" | ||
"github.com/saucelabs/saucectl/internal/region" | ||
) | ||
|
||
func TestValidate(t *testing.T) { | ||
type args struct { | ||
p Project | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
wantErr string | ||
}{ | ||
{ | ||
name: "Passing", | ||
args: args{ | ||
p: Project{ | ||
Sauce: config.SauceConfig{ | ||
Region: region.USWest1.String(), | ||
}, | ||
Suites: []Suite{ | ||
{ | ||
Name: "Main Suite", | ||
Workload: "other", | ||
Image: "dummy/image", | ||
}, | ||
}, | ||
}, | ||
}, | ||
wantErr: "", | ||
}, | ||
{ | ||
name: "No Image", | ||
args: args{ | ||
p: Project{ | ||
Sauce: config.SauceConfig{ | ||
Region: region.USWest1.String(), | ||
}, | ||
Suites: []Suite{ | ||
{ | ||
Name: "Main Suite", | ||
Workload: "other", | ||
}, | ||
}, | ||
}, | ||
}, | ||
wantErr: `missing "image" for suite: Main Suite`, | ||
}, | ||
{ | ||
name: "No Workload Type", | ||
args: args{ | ||
p: Project{ | ||
Sauce: config.SauceConfig{ | ||
Region: region.USWest1.String(), | ||
}, | ||
Suites: []Suite{ | ||
{ | ||
Name: "Main Suite", | ||
Image: "dummy/image", | ||
}, | ||
}, | ||
}, | ||
}, | ||
wantErr: `missing "workload" value for suite: Main Suite`, | ||
}, | ||
{ | ||
name: "Invalid Workload Type", | ||
args: args{ | ||
p: Project{ | ||
Sauce: config.SauceConfig{ | ||
Region: region.USWest1.String(), | ||
}, | ||
Suites: []Suite{ | ||
{ | ||
Name: "Main Suite", | ||
Image: "dummy/image", | ||
Workload: "invalid-workload-type", | ||
}, | ||
}, | ||
}, | ||
}, | ||
wantErr: `"invalid-workload-type" is an invalid "workload" value for suite: Main Suite`, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
err := Validate(tt.args.p) | ||
errStr := "" | ||
if err != nil { | ||
errStr = err.Error() | ||
} | ||
if errStr != tt.wantErr { | ||
t.Errorf("Validate() error = %v, wantErr %v", errStr, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} |
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
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
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