6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-05 19:27:57 +00:00

Refactor pkg directory back

This commit is contained in:
Grzegorz Dlugoszewski
2020-06-12 20:19:05 +02:00
parent 823a522a97
commit 33ca245d3a
16 changed files with 15 additions and 16 deletions

55
pkg/path/bundle_test.go Normal file
View File

@@ -0,0 +1,55 @@
package path
import (
"testing"
)
func TestParsingRefs(t *testing.T) {
var tests = []struct {
line string
wantBranch string
wantErr error
}{
{
line: "https://github.com/grdl/git-get",
wantBranch: "",
wantErr: nil,
},
{
line: "https://github.com/grdl/git-get master",
wantBranch: "master",
wantErr: nil,
},
{
line: "https://github.com/grdl/git-get refs/tags/v1.0.0",
wantBranch: "refs/tags/v1.0.0",
wantErr: nil,
},
{
line: "https://github.com/grdl/git-get master branch",
wantBranch: "",
wantErr: ErrInvalidNumberOfElements,
},
{
line: "https://github.com",
wantBranch: "",
wantErr: ErrEmptyURLPath,
},
}
for i, test := range tests {
got, err := parseLine(test.line)
if err != nil && test.wantErr == nil {
t.Fatalf("Test case %d should not return an error", i)
}
if err != nil && test.wantErr != nil {
continue
}
if got.Branch != test.wantBranch {
t.Errorf("Failed test case %d, got: %s; wantBranch: %s", i, got.Branch, test.wantBranch)
}
}
}