diff options
| author | Segev Finer <[email protected]> | 2020-11-14 02:50:59 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-11-13 16:50:59 -0800 |
| commit | 2bd574b6bd75a044f526cf882161db08ac3cb633 (patch) | |
| tree | 5e5060f5d6c75a3a6396222328ad2670743739f6 /reference_test.go | |
| parent | 2d639d8e49470be188108eeae8e8f722d68aa910 (diff) | |
Add ReferenceNormalizeName (#681)
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 { |
