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

Function TestShortRef

pkg/cli/update_command_test.go:993–1012  ·  view source on GitHub ↗

TestShortRef tests the shortRef helper for abbreviating refs in messages

(t *testing.T)

Source from the content-addressed store, hash-verified

991
992// TestShortRef tests the shortRef helper for abbreviating refs in messages
993func TestShortRef(t *testing.T) {
994 tests := []struct {
995 name string
996 ref string
997 expected string
998 }{
999 {"commit SHA", "ea350161ad5dcc9624cf510f134c6a9e39a6f94d", "ea35016"},
1000 {"branch name", "main", "main"},
1001 {"version tag", "v1.2.3", "v1.2.3"},
1002 {"short string", "abc", "abc"},
1003 {"empty string", "", ""},
1004 }
1005
1006 for _, tt := range tests {
1007 t.Run(tt.name, func(t *testing.T) {
1008 result := shortRef(tt.ref)
1009 assert.Equal(t, tt.expected, result, "shortRef(%q) should return %q", tt.ref, tt.expected)
1010 })
1011 }
1012}
1013
1014// TestIsBranchRef tests the isBranchRef helper that distinguishes branch names
1015// from semantic version tags and commit SHAs

Callers

nothing calls this directly

Calls 2

shortRefFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected