github.phpd.cn/hashicorp/packer@v1.3.2/builder/googlecompute/image_test.go (about) 1 package googlecompute 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func StubImage(name, project string, licenses []string, sizeGb int64) *Image { 11 return &Image{ 12 Licenses: licenses, 13 Name: name, 14 ProjectId: project, 15 SelfLink: fmt.Sprintf("https://www.googleapis.com/compute/v1/projects/%s/global/images/%s", project, name), 16 SizeGb: sizeGb, 17 } 18 } 19 20 func TestImage_IsWindows(t *testing.T) { 21 i := StubImage("foo", "foo-project", []string{"license-foo", "license-bar"}, 100) 22 assert.False(t, i.IsWindows()) 23 24 i = StubImage("foo", "foo-project", []string{"license-foo", "windows-license"}, 100) 25 assert.True(t, i.IsWindows()) 26 }