mirror of https://github.com/rancher/gitjob.git
34 lines
544 B
Go
34 lines
544 B
Go
package webhook
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gotest.tools/assert"
|
|
)
|
|
|
|
func TestGetBranchTagFromRef(t *testing.T) {
|
|
inputs := []string{
|
|
"refs/heads/master",
|
|
"refs/heads/test",
|
|
"refs/head/foo",
|
|
"refs/tags/v0.1.1",
|
|
"refs/tags/v0.1.2",
|
|
"refs/tag/v0.1.3",
|
|
}
|
|
|
|
outputs := [][]string{
|
|
{"master", ""},
|
|
{"test", ""},
|
|
{"", ""},
|
|
{"", "v0.1.1"},
|
|
{"", "v0.1.2"},
|
|
{"", ""},
|
|
}
|
|
|
|
for i, input := range inputs {
|
|
branch, tag := getBranchTagFromRef(input)
|
|
assert.Equal(t, branch, outputs[i][0])
|
|
assert.Equal(t, tag, outputs[i][1])
|
|
}
|
|
}
|