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

Function TestIsMorePreciseVersion

pkg/workflow/action_cache_test.go:490–549  ·  view source on GitHub ↗

TestIsMorePreciseVersion tests the version precision comparison

(t *testing.T)

Source from the content-addressed store, hash-verified

488
489// TestIsMorePreciseVersion tests the version precision comparison
490func TestIsMorePreciseVersion(t *testing.T) {
491 tests := []struct {
492 name string
493 v1 string
494 v2 string
495 expected bool
496 }{
497 {
498 name: "v4.3.0 is more precise than v4",
499 v1: "v4.3.0",
500 v2: "v4",
501 expected: true,
502 },
503 {
504 name: "v4 is less precise than v4.3.0",
505 v1: "v4",
506 v2: "v4.3.0",
507 expected: false,
508 },
509 {
510 name: "v5.0.1 is more precise than v5",
511 v1: "v5.0.1",
512 v2: "v5",
513 expected: true,
514 },
515 {
516 name: "v6.1.0 is more precise than v6",
517 v1: "v6.1.0",
518 v2: "v6",
519 expected: true,
520 },
521 {
522 name: "v1.2.3 vs v1.2.3 (same precision)",
523 v1: "v1.2.3",
524 v2: "v1.2.3",
525 expected: false,
526 },
527 {
528 name: "v1.2.10 vs v1.2.3 (same precision, lexicographic)",
529 v1: "v1.2.10",
530 v2: "v1.2.3",
531 expected: false, // "v1.2.3" > "v1.2.10" lexicographically
532 },
533 {
534 name: "v8.0.0 is more precise than v8",
535 v1: "v8.0.0",
536 v2: "v8",
537 expected: true,
538 },
539 }
540
541 for _, tt := range tests {
542 t.Run(tt.name, func(t *testing.T) {
543 result := semverutil.IsMorePreciseVersion(tt.v1, tt.v2)
544 if result != tt.expected {
545 t.Errorf("semverutil.IsMorePreciseVersion(%q, %q) = %v, want %v", tt.v1, tt.v2, result, tt.expected)
546 }
547 })

Callers

nothing calls this directly

Calls 3

IsMorePreciseVersionFunction · 0.92
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected