TestResolveLatestRef_NotCommitSHA tests that non-SHA refs are handled appropriately
(t *testing.T)
| 966 | |
| 967 | // TestResolveLatestRef_NotCommitSHA tests that non-SHA refs are handled appropriately |
| 968 | func TestResolveLatestRef_NotCommitSHA(t *testing.T) { |
| 969 | tests := []struct { |
| 970 | name string |
| 971 | ref string |
| 972 | expectSHA bool |
| 973 | }{ |
| 974 | {"branch name", "main", false}, |
| 975 | {"short SHA", "abc123", false}, |
| 976 | {"version tag", "v1.0.0", false}, |
| 977 | {"invalid hex", "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", false}, |
| 978 | {"valid SHA lowercase", "abcdef1234567890123456789012345678901234", true}, |
| 979 | {"valid SHA uppercase", "ABCDEF1234567890123456789012345678901234", true}, |
| 980 | } |
| 981 | |
| 982 | for _, tt := range tests { |
| 983 | t.Run(tt.name, func(t *testing.T) { |
| 984 | isValid := IsCommitSHA(tt.ref) |
| 985 | if isValid != tt.expectSHA { |
| 986 | t.Errorf("IsCommitSHA(%q) = %v, expected %v", tt.ref, isValid, tt.expectSHA) |
| 987 | } |
| 988 | }) |
| 989 | } |
| 990 | } |
| 991 | |
| 992 | // TestShortRef tests the shortRef helper for abbreviating refs in messages |
| 993 | func TestShortRef(t *testing.T) { |
nothing calls this directly
no test coverage detected