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

Function TestSpec_PublicAPI_IsCommitSHA

pkg/cli/spec_test.go:44–67  ·  view source on GitHub ↗

TestSpec_PublicAPI_IsCommitSHA validates that IsCommitSHA returns true only for 40-char hex strings. Spec: "Returns true if the string is a full Git commit SHA"

(t *testing.T)

Source from the content-addressed store, hash-verified

42// TestSpec_PublicAPI_IsCommitSHA validates that IsCommitSHA returns true only for 40-char hex strings.
43// Spec: "Returns true if the string is a full Git commit SHA"
44func TestSpec_PublicAPI_IsCommitSHA(t *testing.T) {
45 tests := []struct {
46 name string
47 version string
48 want bool
49 }{
50 {"valid SHA lowercase", "abc123def456789012345678901234567890abcd", true},
51 {"valid SHA uppercase", "ABCDEF1234567890123456789012345678901234", true},
52 {"valid SHA mixed case", "AbCdEf1234567890123456789012345678901234", true},
53 {"invalid - too short", "abc123def456", false},
54 {"invalid - too long", "abc123def456789012345678901234567890abcdef", false},
55 {"invalid - contains non-hex", "abc123def456789012345678901234567890abcg", false},
56 {"invalid - empty", "", false},
57 {"invalid - branch name", "main", false},
58 {"invalid - version tag", "v1.0.0", false},
59 }
60
61 for _, tt := range tests {
62 t.Run(tt.name, func(t *testing.T) {
63 got := cli.IsCommitSHA(tt.version)
64 assert.Equal(t, tt.want, got, "IsCommitSHA(%q) mismatch", tt.version)
65 })
66 }
67}
68
69// TestSpec_PublicAPI_GetVersion validates that GetVersion returns a non-empty string.
70// Spec: "Returns the current CLI version"

Callers

nothing calls this directly

Calls 2

IsCommitSHAFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected