Yeet those builds out!
at main 45 lines 733 B view raw
1package internal 2 3import ( 4 "testing" 5 6 "github.com/TecharoHQ/yeet/internal/yeet" 7) 8 9func TestGitVersion(t *testing.T) { 10 for _, tt := range []struct { 11 name string 12 input string 13 want string 14 }{ 15 { 16 name: "base test", 17 }, 18 { 19 name: "with version starts with v", 20 input: "v1.0.0", 21 want: "1.0.0", 22 }, 23 { 24 name: "with version without v", 25 input: "1.0.0", 26 want: "1.0.0", 27 }, 28 { 29 name: "with version with v and -", 30 input: "v1.0.0-abc123", 31 want: "1.0.0-abc123", 32 }, 33 } { 34 t.Run(tt.name, func(t *testing.T) { 35 yeet.ForceGitVersion = &tt.input 36 got := GitVersion() 37 38 if tt.input != "" { 39 if got != tt.want { 40 t.Errorf("GitVersion() = %v, want %v", got, tt.want) 41 } 42 } 43 }) 44 } 45}