Skip to content

Commit

Permalink
Fix bootstrap unit tests
Browse files Browse the repository at this point in the history
The PR #344 broke unit
tests by not including an IP with a network interface during test setup.
It also exposed a bug where logger was being used before
initialization.
  • Loading branch information
rajathagasthya committed Jan 16, 2025
1 parent 922cfde commit 1a29012
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion agent/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ var _ = Describe("bootstrap", func() {
fakesys.FakeCmdResult{Stdout: "/dev/vda1"},
)

logger = boshlog.NewLogger(boshlog.LevelNone)
udev := boshudev.NewConcreteUdevDevice(runner, logger)
linuxCdrom := boshcdrom.NewLinuxCdrom("/dev/sr0", udev, runner)
linuxCdutil := boshcdrom.NewCdUtil(dirProvider.SettingsDir(), fs, linuxCdrom, logger)
Expand All @@ -1117,7 +1118,6 @@ var _ = Describe("bootstrap", func() {
interfaceConfigurationCreator := boshnet.NewInterfaceConfigurationCreator(logger)

interfaceAddrsProvider = &fakeip.FakeInterfaceAddressesProvider{}
logger = boshlog.NewLogger(boshlog.LevelNone)
kernelIPv6 := boshnet.NewKernelIPv6Impl(fs, runner, logger)
fakeMACAddressDetector = &netfakes.FakeMACAddressDetector{}
err := fs.WriteFileString("/etc/resolv.conf", "8.8.8.8 4.4.4.4")
Expand Down Expand Up @@ -1318,6 +1318,9 @@ var _ = Describe("bootstrap", func() {
Context("and a single physical network interface exists", func() {
BeforeEach(func() {
stubInterfaces([][]string{{"eth0", "aa:bb:cc"}})
interfaceAddrsProvider.GetInterfaceAddresses = []boship.InterfaceAddress{
boship.NewSimpleInterfaceAddress("eth0", "2.2.2.2"),
}
})

It("succeeds", func() {
Expand Down

0 comments on commit 1a29012

Please sign in to comment.