@@ -58,32 +58,39 @@ func TestCreateValidator(t *testing.T) {
5858 },
5959 wantErr : false ,
6060 },
61- "returns error when option is empty" : {
62- c : & mock.Client {},
63- want : nil ,
64- wantErr : true ,
65- },
66- "returns error when client is nil" : {
67- c : nil ,
61+ "returns Validator when invalid string is provided for ignored jobs" : {
62+ c : & mock.Client {},
6863 opts : []Option {
6964 WithGitHubOwnerAndRepo ("test" , "test-repo" ),
7065 WithGitHubRef ("sha" ),
7166 WithGitHubRef ("sha-01" ),
7267 WithSelfJob ("job" ),
7368 WithSelfJob ("job-01" ),
69+ WithIgnoredJobs ("," ), // Malformed but handled
70+ },
71+ want : & statusValidator {
72+ client : & mock.Client {},
73+ owner : "test" ,
74+ repo : "test-repo" ,
75+ ref : "sha-01" ,
76+ selfJobName : "job-01" ,
77+ ignoredJobs : []string {}, // Not nil
7478 },
79+ wantErr : false ,
80+ },
81+ "returns error when option is empty" : {
82+ c : & mock.Client {},
7583 want : nil ,
7684 wantErr : true ,
7785 },
78- "returns error when ignored jobs is an empty string " : {
79- c : & mock. Client {} ,
86+ "returns error when client is nil " : {
87+ c : nil ,
8088 opts : []Option {
8189 WithGitHubOwnerAndRepo ("test" , "test-repo" ),
8290 WithGitHubRef ("sha" ),
8391 WithGitHubRef ("sha-01" ),
8492 WithSelfJob ("job" ),
8593 WithSelfJob ("job-01" ),
86- WithIgnoredJobs ("," ), // Malformed, and causes the error
8794 },
8895 want : nil ,
8996 wantErr : true ,
@@ -376,7 +383,7 @@ func Test_statusValidator_Validate(t *testing.T) {
376383 },
377384 "returns succeeded status and nil when only an ignored job is failing" : {
378385 selfJobName : "self-job" ,
379- ignoredJobs : []string {"job-02 " , "job-03" }, // Some extra space will be trimmed by strings. TrimSpace
386+ ignoredJobs : []string {"job-02" , "job-03" }, // String input here should be already TrimSpace'd
380387 client : & mock.Client {
381388 GetCombinedStatusFunc : func (ctx context.Context , owner , repo , ref string , opts * github.ListOptions ) (* github.CombinedStatus , * github.Response , error ) {
382389 return & github.CombinedStatus {
0 commit comments