diff options
Diffstat (limited to 'reference_test.go')
| -rw-r--r-- | reference_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/reference_test.go b/reference_test.go index b6721e1..e42db41 100644 --- a/reference_test.go +++ b/reference_test.go @@ -224,6 +224,29 @@ func TestReferenceIsValidName(t *testing.T) { } } +func TestReferenceNormalizeName(t *testing.T) { + t.Parallel() + + ref, err := ReferenceNormalizeName("refs/heads//master", ReferenceFormatNormal) + checkFatal(t, err) + + if ref != "refs/heads/master" { + t.Errorf("ReferenceNormalizeName(%q) = %q; want %q", "refs/heads//master", ref, "refs/heads/master") + } + + ref, err = ReferenceNormalizeName("master", ReferenceFormatAllowOnelevel|ReferenceFormatRefspecShorthand) + checkFatal(t, err) + + if ref != "master" { + t.Errorf("ReferenceNormalizeName(%q) = %q; want %q", "master", ref, "master") + } + + ref, err = ReferenceNormalizeName("foo^", ReferenceFormatNormal) + if !IsErrorCode(err, ErrInvalidSpec) { + t.Errorf("foo^ should be invalid") + } +} + func compareStringList(t *testing.T, expected, actual []string) { for i, v := range expected { if actual[i] != v { |
