MCPcopy Create free account
hub / github.com/github/gh-aw / TestResolveLatestRef_NotCommitSHA

Function TestResolveLatestRef_NotCommitSHA

pkg/cli/update_command_test.go:968–990  ·  view source on GitHub ↗

TestResolveLatestRef_NotCommitSHA tests that non-SHA refs are handled appropriately

(t *testing.T)

Source from the content-addressed store, hash-verified

966
967// TestResolveLatestRef_NotCommitSHA tests that non-SHA refs are handled appropriately
968func 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
993func TestShortRef(t *testing.T) {

Callers

nothing calls this directly

Calls 3

IsCommitSHAFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected