github.com/cloudfoundry-incubator/stembuild@v0.0.0-20211223202937-5b61d62226c6/package_stemcell/config/source_config_test.go (about) 1 package config_test 2 3 import ( 4 . "github.com/cloudfoundry-incubator/stembuild/package_stemcell/config" 5 . "github.com/onsi/ginkgo" 6 . "github.com/onsi/gomega" 7 ) 8 9 var _ = Describe("SourceConfig", func() { 10 Describe("GetSource", func() { 11 It("returns no error when VMDK configured correctly", func() { 12 config := SourceConfig{ 13 Vmdk: "/some/path/to/a/file", 14 } 15 source, err := config.GetSource() 16 Expect(err).NotTo(HaveOccurred()) 17 Expect(source).To(Equal(VMDK)) 18 }) 19 20 It("returns an error when no configuration provided", func() { 21 config := SourceConfig{} 22 source, err := config.GetSource() 23 Expect(err).To(MatchError("no configuration was provided")) 24 Expect(source).To(Equal(NIL)) 25 }) 26 27 It("return no error when vCenter configured correctly", func() { 28 config := SourceConfig{ 29 VmInventoryPath: "/my-datacenter/vm/my-folder/my-vm", 30 Username: "user", 31 Password: "pass", 32 URL: "https://vcenter.test", 33 } 34 source, err := config.GetSource() 35 Expect(err).NotTo(HaveOccurred()) 36 Expect(source).To(Equal(VCENTER)) 37 38 }) 39 40 It("returns an error when both VMDK and Vcenter configured", func() { 41 config := SourceConfig{ 42 Vmdk: "/some/path/to/a/file", 43 VmInventoryPath: "/my-datacenter/vm/my-folder/my-vm", 44 Username: "user", 45 Password: "pass", 46 URL: "https://vcenter.test", 47 } 48 source, err := config.GetSource() 49 Expect(err).To(MatchError("configuration provided for VMDK & vCenter sources")) 50 Expect(source).To(Equal(NIL)) 51 52 }) 53 54 It("returns an error when Vcenter configurations only partially specified", func() { 55 config := SourceConfig{ 56 VmInventoryPath: "/my-datacenter/vm/my-folder/my-vm", 57 Username: "user", 58 URL: "https://vcenter.test", 59 } 60 source, err := config.GetSource() 61 Expect(err).To(MatchError("missing vCenter configurations")) 62 Expect(source).To(Equal(NIL)) 63 }) 64 65 }) 66 67 })