-
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.
Merge pull request #9 from LinuxSuRen/skip-status
feat: skip sending status if pr is -1
- Loading branch information
Showing
3 changed files
with
84 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
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,46 @@ | ||
package pkg | ||
|
||
import ( | ||
"context" | ||
"github.com/jenkins-x/go-scm/scm" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestReconcile(t *testing.T) { | ||
type args struct { | ||
ctx context.Context | ||
repoInfo RepoInformation | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
wantErr bool | ||
}{{ | ||
name: "pr number is -1", | ||
args: args{ | ||
repoInfo: RepoInformation{ | ||
PrNumber: -1, | ||
}, | ||
}, | ||
wantErr: false, | ||
}} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if err := Reconcile(tt.args.ctx, tt.args.repoInfo); (err != nil) != tt.wantErr { | ||
t.Errorf("Reconcile() error = %v, wantErr %v", err, tt.wantErr) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestNewStatusMaker(t *testing.T) { | ||
maker := NewStatusMaker("", "") | ||
assert.NotNil(t, maker) | ||
assert.NotNil(t, maker.expirationCheck) | ||
assert.False(t, maker.expirationCheck(nil, nil)) | ||
assert.False(t, maker.expirationCheck(&scm.Status{State: scm.StateSuccess}, | ||
&scm.StatusInput{State: scm.StateError})) | ||
assert.True(t, maker.expirationCheck(&scm.Status{State: scm.StateSuccess}, | ||
&scm.StatusInput{State: scm.StateSuccess})) | ||
} |
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,33 @@ | ||
package pkg | ||
|
||
import "testing" | ||
|
||
func TestRepoInformation_getRepoPath(t *testing.T) { | ||
type fields struct { | ||
Owner string | ||
Repo string | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want string | ||
}{{ | ||
name: "normal case", | ||
fields: fields{ | ||
Owner: "owner", | ||
Repo: "repo", | ||
}, | ||
want: "owner/repo", | ||
}} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
r := RepoInformation{ | ||
Owner: tt.fields.Owner, | ||
Repo: tt.fields.Repo, | ||
} | ||
if got := r.getRepoPath(); got != tt.want { | ||
t.Errorf("getRepoPath() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |