TestIsCommitSHA_Integration tests commit SHA identification with real-world examples.
(t *testing.T)
| 407 | |
| 408 | // TestIsCommitSHA_Integration tests commit SHA identification with real-world examples. |
| 409 | func TestIsCommitSHA_Integration(t *testing.T) { |
| 410 | tests := []struct { |
| 411 | name string |
| 412 | ref string |
| 413 | expected bool |
| 414 | }{ |
| 415 | {"real commit SHA", "6c79ed2ea350161ad5dcc9624cf510f134c6a9e3", true}, |
| 416 | {"another SHA", "f43a0e5ff2bd294095638e18286ca9a3d1956744", true}, |
| 417 | {"v-prefixed tag", "v1.2.3", false}, |
| 418 | {"branch name", "main", false}, |
| 419 | {"short SHA", "6c79ed2", false}, |
| 420 | {"39 chars", "6c79ed2ea350161ad5dcc9624cf510f134c6a9e", false}, |
| 421 | {"41 chars", "6c79ed2ea350161ad5dcc9624cf510f134c6a9e39", false}, |
| 422 | {"non-hex 40 chars", "ghijklmnopqrstuvwxyz12345678901234567890", false}, |
| 423 | } |
| 424 | |
| 425 | for _, tt := range tests { |
| 426 | t.Run(tt.name, func(t *testing.T) { |
| 427 | assert.Equal(t, tt.expected, IsCommitSHA(tt.ref), "IsCommitSHA(%q)", tt.ref) |
| 428 | }) |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | // --- Helper Function Tests --- |
| 433 |
nothing calls this directly
no test coverage detected