mirror of
https://github.com/thegeeklab/wp-docker-buildx.git
synced 2024-11-10 03:30:40 +00:00
add unit test.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
13ce200771
commit
ce53e21989
@ -23,3 +23,45 @@ func Test_stripHeadPrefix(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUseDefaultTag(t *testing.T) {
|
||||||
|
type args struct {
|
||||||
|
ref string
|
||||||
|
defaultBranch string
|
||||||
|
}
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
args args
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "latest tag for default branch",
|
||||||
|
args: args{
|
||||||
|
ref: "refs/heads/master",
|
||||||
|
defaultBranch: "master",
|
||||||
|
},
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "build from tags",
|
||||||
|
args: args{
|
||||||
|
ref: "refs/tags/v1.0.0",
|
||||||
|
defaultBranch: "master",
|
||||||
|
},
|
||||||
|
want: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "skip build for not default branch",
|
||||||
|
args: args{
|
||||||
|
ref: "refs/heads/develop",
|
||||||
|
defaultBranch: "master",
|
||||||
|
},
|
||||||
|
want: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tt := range tests {
|
||||||
|
if got := UseDefaultTag(tt.args.ref, tt.args.defaultBranch); got != tt.want {
|
||||||
|
t.Errorf("%q. UseDefaultTag() = %v, want %v", tt.name, got, tt.want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user