github.com/seilagamo/poc-lava-release@v0.3.3-rc3/internal/assettypes/assettypes_test.go (about) 1 // Copyright 2023 Adevinta 2 3 package assettypes 4 5 import ( 6 "testing" 7 8 types "github.com/adevinta/vulcan-types" 9 ) 10 11 func TestIsValid(t *testing.T) { 12 tests := []struct { 13 name string 14 at types.AssetType 15 want bool 16 }{ 17 { 18 name: "lava type", 19 at: Path, 20 want: true, 21 }, 22 { 23 name: "vulcan type", 24 at: types.Hostname, 25 want: false, 26 }, 27 { 28 name: "zero value", 29 at: types.AssetType(""), 30 want: false, 31 }, 32 } 33 34 for _, tt := range tests { 35 t.Run(tt.name, func(t *testing.T) { 36 got := IsValid(tt.at) 37 if got != tt.want { 38 t.Errorf("unexpected value: want: %v, got: %v", tt.want, got) 39 } 40 }) 41 } 42 } 43 44 func TestToVulcan(t *testing.T) { 45 tests := []struct { 46 name string 47 at types.AssetType 48 want types.AssetType 49 }{ 50 { 51 name: "lava type", 52 at: Path, 53 want: types.GitRepository, 54 }, 55 { 56 name: "vulcan type", 57 at: types.Hostname, 58 want: types.Hostname, 59 }, 60 { 61 name: "zero value", 62 at: types.AssetType(""), 63 want: types.AssetType(""), 64 }, 65 } 66 67 for _, tt := range tests { 68 t.Run(tt.name, func(t *testing.T) { 69 got := ToVulcan(tt.at) 70 if got != tt.want { 71 t.Errorf("unexpected value: want: %v, got: %v", tt.want, got) 72 } 73 }) 74 } 75 }