diff --git a/colorlogger/colorLogger_test.go b/colorlogger/colorLogger_test.go index 6a284e6b..a4c5d5af 100644 --- a/colorlogger/colorLogger_test.go +++ b/colorlogger/colorLogger_test.go @@ -3,7 +3,7 @@ package colorlogger_test import ( "bytes" - . "github.com/cloudfoundry/stembuild/colorlogger" + "github.com/cloudfoundry/stembuild/colorlogger" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -13,45 +13,45 @@ var _ = Describe("Stdout", func() { It("write debug output when log level is debug", func() { buf := bytes.Buffer{} - Expect(DEBUG).To(Equal(0)) - logger := ConstructLogger(DEBUG, false, &buf) + Expect(colorlogger.DEBUG).To(Equal(0)) + logger := colorlogger.ConstructLogger(colorlogger.DEBUG, false, &buf) message := "This is a test" - logger.Logf(DEBUG, message) + logger.Logf(colorlogger.DEBUG, message) Expect(buf.String()).To(Equal("debug: " + message + "\n")) }) It("write no debug output when log level is NONE", func() { buf := bytes.Buffer{} - logger := ConstructLogger(NONE, false, &buf) + logger := colorlogger.ConstructLogger(colorlogger.NONE, false, &buf) message := "This is a test" - logger.Logf(DEBUG, message) + logger.Logf(colorlogger.DEBUG, message) Expect(buf.String()).To(BeEmpty()) }) It("write no none output when log level is NONE", func() { buf := bytes.Buffer{} - logger := ConstructLogger(NONE, false, &buf) + logger := colorlogger.ConstructLogger(colorlogger.NONE, false, &buf) message := "This is a test" - logger.Logf(NONE, message) + logger.Logf(colorlogger.NONE, message) Expect(buf.String()).To(BeEmpty()) }) It("write colored debug output when log level is DEBUG and color is true", func() { buf := bytes.Buffer{} - logger := ConstructLogger(DEBUG, true, &buf) + logger := colorlogger.ConstructLogger(colorlogger.DEBUG, true, &buf) message := "This is a test" - logger.Logf(DEBUG, message) + logger.Logf(colorlogger.DEBUG, message) Expect(buf.String()).To(Equal("\033[32mdebug:\033[0m " + message + "\n")) }) diff --git a/commandparser/construct_helpers_test.go b/commandparser/construct_helpers_test.go index a9eccfb1..f18cfdb6 100644 --- a/commandparser/construct_helpers_test.go +++ b/commandparser/construct_helpers_test.go @@ -3,7 +3,7 @@ package commandparser_test import ( "path/filepath" - . "github.com/cloudfoundry/stembuild/commandparser" + "github.com/cloudfoundry/stembuild/commandparser" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -20,7 +20,7 @@ var _ = Describe("construct_helpers", func() { dir := filepath.Join("..", "test", "constructData", "emptyDir") It("should return false with no error", func() { - present, err := IsArtifactInDirectory(dir, filename) + present, err := commandparser.IsArtifactInDirectory(dir, filename) Expect(err).ToNot(HaveOccurred()) Expect(present).To(BeFalse()) }) @@ -30,7 +30,7 @@ var _ = Describe("construct_helpers", func() { dir := filepath.Join("..", "test", "constructData", "fullDir") It("should return true with no error", func() { - present, err := IsArtifactInDirectory(dir, filename) + present, err := commandparser.IsArtifactInDirectory(dir, filename) Expect(err).ToNot(HaveOccurred()) Expect(present).To(BeTrue()) }) @@ -42,7 +42,7 @@ var _ = Describe("construct_helpers", func() { filename := "file" It("should return an error", func() { dir := filepath.Join("..", "test", "constructData", "notExist") - _, err := IsArtifactInDirectory(dir, filename) + _, err := commandparser.IsArtifactInDirectory(dir, filename) Expect(err).To(HaveOccurred()) }) }) diff --git a/commandparser/construct_test.go b/commandparser/construct_test.go index ce7d0a0a..2ea9c566 100644 --- a/commandparser/construct_test.go +++ b/commandparser/construct_test.go @@ -5,7 +5,7 @@ import ( "errors" "flag" - . "github.com/cloudfoundry/stembuild/commandparser" + "github.com/cloudfoundry/stembuild/commandparser" "github.com/cloudfoundry/stembuild/commandparser/commandparserfakes" "github.com/google/subcommands" @@ -20,11 +20,11 @@ var _ = Describe("construct", func() { Describe("SetFlags", func() { var f *flag.FlagSet - var ConstrCmd *ConstructCmd + var ConstrCmd *commandparser.ConstructCmd BeforeEach(func() { f = flag.NewFlagSet("test", flag.ContinueOnError) - ConstrCmd = &ConstructCmd{} + ConstrCmd = &commandparser.ConstructCmd{} ConstrCmd.SetFlags(f) }) @@ -138,8 +138,8 @@ var _ = Describe("construct", func() { Describe("Execute", func() { var f *flag.FlagSet - var gf *GlobalFlags - var ConstrCmd *ConstructCmd + var gf *commandparser.GlobalFlags + var ConstrCmd *commandparser.ConstructCmd var emptyContext context.Context var fakeFactory *commandparserfakes.FakeVMPreparerFactory @@ -150,7 +150,7 @@ var _ = Describe("construct", func() { BeforeEach(func() { f = flag.NewFlagSet("test", flag.ExitOnError) - gf = &GlobalFlags{false, false, false} + gf = &commandparser.GlobalFlags{false, false, false} fakeFactory = &commandparserfakes.FakeVMPreparerFactory{} fakeVmConstruct = &commandparserfakes.FakeVmConstruct{} @@ -159,7 +159,7 @@ var _ = Describe("construct", func() { fakeManagerFactory = &commandparserfakes.FakeManagerFactory{} fakeFactory.VMPreparerReturns(fakeVmConstruct, nil) - ConstrCmd = NewConstructCmd(context.Background(), fakeFactory, fakeManagerFactory, fakeValidator, fakeMessenger) + ConstrCmd = commandparser.NewConstructCmd(context.Background(), fakeFactory, fakeManagerFactory, fakeValidator, fakeMessenger) ConstrCmd.SetFlags(f) ConstrCmd.GlobalFlags = gf emptyContext = context.Background() diff --git a/commandparser/help_test.go b/commandparser/help_test.go index 22f4096f..ba877fbd 100644 --- a/commandparser/help_test.go +++ b/commandparser/help_test.go @@ -7,7 +7,7 @@ import ( "os" "path" - . "github.com/cloudfoundry/stembuild/commandparser" + "github.com/cloudfoundry/stembuild/commandparser" "github.com/cloudfoundry/stembuild/version" "github.com/google/subcommands" . "github.com/onsi/ginkgo/v2" @@ -24,7 +24,7 @@ var _ = Describe("help", func() { buf := bytes.Buffer{} fs := flag.NewFlagSet(path.Base(os.Args[0]), flag.ExitOnError) commands := make([]subcommands.Command, 0) - sb := NewStembuildHelp(subcommands.DefaultCommander, fs, &commands) + sb := commandparser.NewStembuildHelp(subcommands.DefaultCommander, fs, &commands) sb.Explain(&buf) diff --git a/integration/construct/winrm_test.go b/integration/construct/winrm_test.go index 72b589b5..fd7ae0cd 100644 --- a/integration/construct/winrm_test.go +++ b/integration/construct/winrm_test.go @@ -3,18 +3,18 @@ package construct_test import ( "path/filepath" - . "github.com/cloudfoundry/stembuild/remotemanager" + "github.com/cloudfoundry/stembuild/remotemanager" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) var _ = Describe("WinRM Remote Manager", func() { - var rm RemoteManager + var rm remotemanager.RemoteManager BeforeEach(func() { - clientFactory := NewWinRmClientFactory(conf.TargetIP, conf.VMUsername, conf.VMPassword) - rm = NewWinRM(conf.TargetIP, conf.VMUsername, conf.VMPassword, clientFactory) + clientFactory := remotemanager.NewWinRmClientFactory(conf.TargetIP, conf.VMUsername, conf.VMPassword) + rm = remotemanager.NewWinRM(conf.TargetIP, conf.VMUsername, conf.VMPassword, clientFactory) Expect(rm).ToNot(BeNil()) }) diff --git a/package_stemcell/config/output_config_test.go b/package_stemcell/config/output_config_test.go index 70de5f82..07db4b67 100644 --- a/package_stemcell/config/output_config_test.go +++ b/package_stemcell/config/output_config_test.go @@ -4,7 +4,7 @@ import ( "os" "path/filepath" - . "github.com/cloudfoundry/stembuild/package_stemcell/config" + "github.com/cloudfoundry/stembuild/package_stemcell/config" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -13,36 +13,36 @@ var _ = Describe("OutputConfig", func() { Describe("os", func() { Context("no os specified", func() { It("should be invalid", func() { - valid := IsValidOS("") + valid := config.IsValidOS("") Expect(valid).To(BeFalse()) }) }) Context("a supported os is specified", func() { It("2016 should be valid", func() { - valid := IsValidOS("2016") + valid := config.IsValidOS("2016") Expect(valid).To(BeTrue()) }) It("2012R2 should be valid", func() { - valid := IsValidOS("2012R2") + valid := config.IsValidOS("2012R2") Expect(valid).To(BeTrue()) }) It("1803 should be valid", func() { - valid := IsValidOS("1803") + valid := config.IsValidOS("1803") Expect(valid).To(BeTrue()) }) It("2019 should be valid", func() { - valid := IsValidOS("2019") + valid := config.IsValidOS("2019") Expect(valid).To(BeTrue()) }) }) Context("something other than a supported os is specified", func() { It("should be invalid", func() { - valid := IsValidOS("bad-thing") + valid := config.IsValidOS("bad-thing") Expect(valid).To(BeFalse()) }) It("1709 should be invalid", func() { - valid := IsValidOS("1709") + valid := config.IsValidOS("1709") Expect(valid).To(BeFalse()) }) }) @@ -51,7 +51,7 @@ var _ = Describe("OutputConfig", func() { Describe("stemcell version", func() { Context("no stemcell version specified", func() { It("should be invalid", func() { - valid := IsValidStemcellVersion("") + valid := config.IsValidStemcellVersion("") Expect(valid).To(BeFalse()) }) }) @@ -59,14 +59,14 @@ var _ = Describe("OutputConfig", func() { It("should be valid", func() { valids := []string{"4.4", "4.4-build.1", "4.4.4", "4.4.4-build.4"} for _, version := range valids { - valid := IsValidStemcellVersion(version) + valid := config.IsValidStemcellVersion(version) Expect(valid).To(BeTrue()) } }) }) Context("stemcell version specified is invalid pattern", func() { It("should be invalid", func() { - valid := IsValidStemcellVersion("4.4.4.4") + valid := config.IsValidStemcellVersion("4.4.4.4") Expect(valid).To(BeFalse()) }) }) @@ -75,7 +75,7 @@ var _ = Describe("OutputConfig", func() { Describe("validateOutputDir", func() { Context("no dir given", func() { It("should be an error", func() { - err := ValidateOrCreateOutputDir("") + err := config.ValidateOrCreateOutputDir("") Expect(err).To(HaveOccurred()) }) }) @@ -84,7 +84,7 @@ var _ = Describe("OutputConfig", func() { It("should create the directory and not fail", func() { err := os.RemoveAll(filepath.Join(".", "tmp")) Expect(err).ToNot(HaveOccurred()) - err = ValidateOrCreateOutputDir(filepath.Join(".", "tmp")) + err = config.ValidateOrCreateOutputDir(filepath.Join(".", "tmp")) Expect(err).ToNot(HaveOccurred()) _, err = os.Stat(filepath.Join(filepath.Join(".", "tmp"))) Expect(err).ToNot(HaveOccurred()) @@ -99,7 +99,7 @@ var _ = Describe("OutputConfig", func() { It("should not fail", func() { err := os.Mkdir(filepath.Join(".", "tmp"), 0700) Expect(err).ToNot(HaveOccurred()) - err = ValidateOrCreateOutputDir(filepath.Join(".", "tmp")) + err = config.ValidateOrCreateOutputDir(filepath.Join(".", "tmp")) Expect(err).ToNot(HaveOccurred()) }) AfterEach(func() { @@ -112,7 +112,7 @@ var _ = Describe("OutputConfig", func() { It("should not fail", func() { cwd, err := os.Getwd() Expect(err).ToNot(HaveOccurred()) - err = ValidateOrCreateOutputDir(cwd) + err = config.ValidateOrCreateOutputDir(cwd) Expect(err).ToNot(HaveOccurred()) }) }) @@ -121,7 +121,7 @@ var _ = Describe("OutputConfig", func() { It("should be an error", func() { err := os.RemoveAll(filepath.Join(".", "tmp")) Expect(err).ToNot(HaveOccurred()) - err = ValidateOrCreateOutputDir(filepath.Join(".", "tmp", "subtmp")) + err = config.ValidateOrCreateOutputDir(filepath.Join(".", "tmp", "subtmp")) Expect(err).To(HaveOccurred()) }) }) diff --git a/package_stemcell/config/source_config_test.go b/package_stemcell/config/source_config_test.go index 30961de2..87909ea9 100644 --- a/package_stemcell/config/source_config_test.go +++ b/package_stemcell/config/source_config_test.go @@ -1,7 +1,7 @@ package config_test import ( - . "github.com/cloudfoundry/stembuild/package_stemcell/config" + "github.com/cloudfoundry/stembuild/package_stemcell/config" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -9,57 +9,57 @@ import ( var _ = Describe("SourceConfig", func() { Describe("GetSource", func() { It("returns no error when VMDK configured correctly", func() { - config := SourceConfig{ + srcConfig := config.SourceConfig{ Vmdk: "/some/path/to/a/file", } - source, err := config.GetSource() + source, err := srcConfig.GetSource() Expect(err).NotTo(HaveOccurred()) - Expect(source).To(Equal(VMDK)) + Expect(source).To(Equal(config.VMDK)) }) It("returns an error when no configuration provided", func() { - config := SourceConfig{} - source, err := config.GetSource() + srcConfig := config.SourceConfig{} + source, err := srcConfig.GetSource() Expect(err).To(MatchError("no configuration was provided")) - Expect(source).To(Equal(NIL)) + Expect(source).To(Equal(config.NIL)) }) It("return no error when vCenter configured correctly", func() { - config := SourceConfig{ + srcConfig := config.SourceConfig{ VmInventoryPath: "/my-datacenter/vm/my-folder/my-vm", Username: "user", Password: "pass", URL: "https://vcenter.test", } - source, err := config.GetSource() + source, err := srcConfig.GetSource() Expect(err).NotTo(HaveOccurred()) - Expect(source).To(Equal(VCENTER)) + Expect(source).To(Equal(config.VCENTER)) }) It("returns an error when both VMDK and Vcenter configured", func() { - config := SourceConfig{ + srcConfig := config.SourceConfig{ Vmdk: "/some/path/to/a/file", VmInventoryPath: "/my-datacenter/vm/my-folder/my-vm", Username: "user", Password: "pass", URL: "https://vcenter.test", } - source, err := config.GetSource() + source, err := srcConfig.GetSource() Expect(err).To(MatchError("configuration provided for VMDK & vCenter sources")) - Expect(source).To(Equal(NIL)) + Expect(source).To(Equal(config.NIL)) }) It("returns an error when Vcenter configurations only partially specified", func() { - config := SourceConfig{ + srcConfig := config.SourceConfig{ VmInventoryPath: "/my-datacenter/vm/my-folder/my-vm", Username: "user", URL: "https://vcenter.test", } - source, err := config.GetSource() + source, err := srcConfig.GetSource() Expect(err).To(MatchError("missing vCenter configurations")) - Expect(source).To(Equal(NIL)) + Expect(source).To(Equal(config.NIL)) }) }) diff --git a/package_stemcell/package_parameters/vmdk_package_parameters_test.go b/package_stemcell/package_parameters/vmdk_package_parameters_test.go index 1dd444e4..4e808b7a 100644 --- a/package_stemcell/package_parameters/vmdk_package_parameters_test.go +++ b/package_stemcell/package_parameters/vmdk_package_parameters_test.go @@ -4,7 +4,7 @@ import ( "fmt" "math/rand" - . "github.com/cloudfoundry/stembuild/package_stemcell/package_parameters" + "github.com/cloudfoundry/stembuild/package_stemcell/package_parameters" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -12,13 +12,13 @@ import ( var _ = Describe("VmdkPackageParameters", func() { Context("CopyFrom", func() { var ( - dest VmdkPackageParameters - src VmdkPackageParameters + dest package_parameters.VmdkPackageParameters + src package_parameters.VmdkPackageParameters ) BeforeEach(func() { - src = VmdkPackageParameters{} - dest = VmdkPackageParameters{} + src = package_parameters.VmdkPackageParameters{} + dest = package_parameters.VmdkPackageParameters{} }) JustBeforeEach(func() { @@ -211,7 +211,7 @@ var _ = Describe("VmdkPackageParameters", func() { }) It("copies into dest only those fields which are empty in dest", func() { - expected := VmdkPackageParameters{ + expected := package_parameters.VmdkPackageParameters{ OSVersion: "the", OutputDir: "needful", Version: "do", diff --git a/package_stemcell/packagers/vcenter_packager_test.go b/package_stemcell/packagers/vcenter_packager_test.go index b568ae1f..c9fcf4ad 100644 --- a/package_stemcell/packagers/vcenter_packager_test.go +++ b/package_stemcell/packagers/vcenter_packager_test.go @@ -12,12 +12,11 @@ import ( "path" "path/filepath" - . "github.com/cloudfoundry/stembuild/package_stemcell/packagers" - "github.com/cloudfoundry/stembuild/filesystem" + "github.com/cloudfoundry/stembuild/package_stemcell/config" + "github.com/cloudfoundry/stembuild/package_stemcell/packagers" "github.com/cloudfoundry/stembuild/package_stemcell/packagers/packagersfakes" - "github.com/cloudfoundry/stembuild/package_stemcell/config" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -43,7 +42,7 @@ var _ = Describe("VcenterPackager", func() { Context("ValidateSourceParameters", func() { It("returns an error if the vCenter url is invalid", func() { fakeVcenterClient.ValidateUrlReturns(errors.New("vcenter client url error")) - packager := VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} + packager := packagers.VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} err := packager.ValidateSourceParameters() @@ -54,7 +53,7 @@ var _ = Describe("VcenterPackager", func() { }) It("returns an error if the vCenter credentials are not valid", func() { fakeVcenterClient.ValidateCredentialsReturns(errors.New("vcenter client credential error")) - packager := VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} + packager := packagers.VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} err := packager.ValidateSourceParameters() @@ -65,7 +64,7 @@ var _ = Describe("VcenterPackager", func() { It("returns an error if VM given does not exist ", func() { fakeVcenterClient.FindVMReturns(errors.New("vcenter client vm error")) - packager := VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} + packager := packagers.VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} err := packager.ValidateSourceParameters() @@ -74,7 +73,7 @@ var _ = Describe("VcenterPackager", func() { Expect(err.Error()).To(Equal("vcenter client vm error")) }) It("returns no error if all source parameters are valid", func() { - packager := VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} + packager := packagers.VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} err := packager.ValidateSourceParameters() @@ -83,7 +82,7 @@ var _ = Describe("VcenterPackager", func() { }) Context("ValidateFreeSpace", func() { It("is a NOOP", func() { - packager := VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} + packager := packagers.VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} err := packager.ValidateFreeSpaceForPackage(&filesystem.OSFileSystem{}) Expect(err).To(Not(HaveOccurred())) @@ -91,7 +90,7 @@ var _ = Describe("VcenterPackager", func() { }) Describe("Package", func() { - var packager *VCenterPackager + var packager *packagers.VCenterPackager AfterEach(func() { _ = os.RemoveAll("./valid-vm-name") @@ -99,7 +98,7 @@ var _ = Describe("VcenterPackager", func() { }) BeforeEach(func() { - packager = &VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} + packager = &packagers.VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} fakeVcenterClient.ExportVMStub = func(vmInventoryPath string, destination string) error { vmName := path.Base(vmInventoryPath) @@ -116,7 +115,7 @@ var _ = Describe("VcenterPackager", func() { err := packager.Package() Expect(err).To(Not(HaveOccurred())) - stemcellFilename := StemcellFilename(packager.OutputConfig.StemcellVersion, packager.OutputConfig.Os) + stemcellFilename := packagers.StemcellFilename(packager.OutputConfig.StemcellVersion, packager.OutputConfig.Os) stemcellFile := filepath.Join(packager.OutputConfig.OutputDir, stemcellFilename) _, err = os.Stat(stemcellFile) @@ -223,7 +222,7 @@ stemcell_formats: }) It("Returns a error message if exporting the VM fails", func() { - packager := VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} + packager := packagers.VCenterPackager{SourceConfig: sourceConfig, OutputConfig: outputConfig, Client: fakeVcenterClient} fakeVcenterClient.ExportVMReturns(errors.New("some client error")) err := packager.Package() diff --git a/package_stemcell/packagers/vmdk_packager_test.go b/package_stemcell/packagers/vmdk_packager_test.go index d441141d..3df79053 100644 --- a/package_stemcell/packagers/vmdk_packager_test.go +++ b/package_stemcell/packagers/vmdk_packager_test.go @@ -8,12 +8,12 @@ import ( "os" "path/filepath" - "github.com/golang/mock/gomock" - - . "github.com/cloudfoundry/stembuild/filesystem/mock" + mock_filesystem "github.com/cloudfoundry/stembuild/filesystem/mock" "github.com/cloudfoundry/stembuild/package_stemcell/package_parameters" "github.com/cloudfoundry/stembuild/package_stemcell/packagers" "github.com/cloudfoundry/stembuild/test/helpers" + + "github.com/golang/mock/gomock" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -123,7 +123,7 @@ var _ = Describe("VmdkPackager", func() { Describe("ValidateFreeSpaceForPackage", func() { var ( mockCtrl *gomock.Controller - mockFileSystem *MockFileSystem + mockFileSystem *mock_filesystem.MockFileSystem ) Context("When VMDK file is invalid", func() { @@ -131,7 +131,7 @@ var _ = Describe("VmdkPackager", func() { c.BuildOptions.VMDKFile = "" mockCtrl = gomock.NewController(GinkgoT()) - mockFileSystem = NewMockFileSystem(mockCtrl) + mockFileSystem = mock_filesystem.NewMockFileSystem(mockCtrl) err := c.ValidateFreeSpaceForPackage(mockFileSystem) Expect(err).To(HaveOccurred()) @@ -145,7 +145,7 @@ var _ = Describe("VmdkPackager", func() { c.BuildOptions.VMDKFile = filepath.Join("..", "..", "test", "data", "expected.vmdk") mockCtrl = gomock.NewController(GinkgoT()) - mockFileSystem = NewMockFileSystem(mockCtrl) + mockFileSystem = mock_filesystem.NewMockFileSystem(mockCtrl) vmdkFile, err := os.Stat(c.BuildOptions.VMDKFile) Expect(err).ToNot(HaveOccurred()) @@ -166,7 +166,7 @@ var _ = Describe("VmdkPackager", func() { c.BuildOptions.VMDKFile = filepath.Join("..", "..", "test", "data", "expected.vmdk") mockCtrl = gomock.NewController(GinkgoT()) - mockFileSystem = NewMockFileSystem(mockCtrl) + mockFileSystem = mock_filesystem.NewMockFileSystem(mockCtrl) vmdkFile, err := os.Stat(c.BuildOptions.VMDKFile) Expect(err).ToNot(HaveOccurred()) @@ -191,7 +191,7 @@ var _ = Describe("VmdkPackager", func() { c.BuildOptions.VMDKFile = filepath.Join("..", "..", "test", "data", "expected.vmdk") mockCtrl = gomock.NewController(GinkgoT()) - mockFileSystem = NewMockFileSystem(mockCtrl) + mockFileSystem = mock_filesystem.NewMockFileSystem(mockCtrl) directoryPath := filepath.Dir(c.BuildOptions.VMDKFile) mockFileSystem.EXPECT().GetAvailableDiskSpace(directoryPath).Return(uint64(4), errors.New("some error")).AnyTimes() diff --git a/remotemanager/winrm_rebootchecker_test.go b/remotemanager/winrm_rebootchecker_test.go index 46bb9d44..437658e9 100644 --- a/remotemanager/winrm_rebootchecker_test.go +++ b/remotemanager/winrm_rebootchecker_test.go @@ -5,11 +5,12 @@ import ( "time" "github.com/cloudfoundry/stembuild/poller/pollerfakes" - . "github.com/cloudfoundry/stembuild/remotemanager" + "github.com/cloudfoundry/stembuild/remotemanager" "github.com/cloudfoundry/stembuild/remotemanager/remotemanagerfakes" + "github.com/pkg/errors" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/pkg/errors" ) const expectedTryCheckRebootCommand = "shutdown /r /f /t 60 /c \"stembuild reboot test\"" @@ -21,14 +22,14 @@ var _ = Describe("WinRM RebootChecker", func() { var ( fakeRemoteManager *remotemanagerfakes.FakeRemoteManager fakePoller *pollerfakes.FakePollerI - rc *RebootChecker + rc *remotemanager.RebootChecker ) BeforeEach(func() { fakeRemoteManager = &remotemanagerfakes.FakeRemoteManager{} fakePoller = &pollerfakes.FakePollerI{} - rc = NewRebootChecker(fakeRemoteManager) + rc = remotemanager.NewRebootChecker(fakeRemoteManager) }) Describe("WaitForRebootFinished", func() { It("calls the hasFinished func using the Poller", func() { @@ -42,7 +43,7 @@ var _ = Describe("WinRM RebootChecker", func() { rc := &remotemanagerfakes.FakeRebootCheckerI{} rc.RebootHasFinishedReturns(false, nil) - waiter := NewRebootWaiter(fakePoller, rc) + waiter := remotemanager.NewRebootWaiter(fakePoller, rc) _ = waiter.WaitForRebootFinished() @@ -58,7 +59,7 @@ var _ = Describe("WinRM RebootChecker", func() { rc := &remotemanagerfakes.FakeRebootCheckerI{} rc.RebootHasFinishedReturns(false, nil) - waiter := NewRebootWaiter(fakePoller, rc) + waiter := remotemanager.NewRebootWaiter(fakePoller, rc) err := waiter.WaitForRebootFinished() Expect(err).ToNot(HaveOccurred()) @@ -68,7 +69,7 @@ var _ = Describe("WinRM RebootChecker", func() { errorMessage := "unable to abort reboot." fakePoller.PollReturns(errors.New(errorMessage)) - waiter := NewRebootWaiter(fakePoller, rc) + waiter := remotemanager.NewRebootWaiter(fakePoller, rc) err := waiter.WaitForRebootFinished() Expect(err.Error()).To(ContainSubstring(errorMessage))