Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/pipelines/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ func (p *UpPipeline) Execute(ctx context.Context) error {

// Configure DNS settings
if dnsEnabled := p.configHandler.GetBool("dns.enabled"); dnsEnabled {
fmt.Fprintf(os.Stderr, "→ ⚠️ DNS configuration may require administrative privileges\n")

if err := p.networkManager.ConfigureDNS(); err != nil {
return fmt.Errorf("Error configuring DNS: %w", err)
}
Expand Down
56 changes: 41 additions & 15 deletions pkg/pipelines/up_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,19 +483,52 @@ func TestUpPipeline_Execute(t *testing.T) {
}
})

t.Run("SkipsDNSWhenDisabled", func(t *testing.T) {
// Given a pipeline with DNS disabled
t.Run("ShowsDNSNotificationWhenEnabled", func(t *testing.T) {
// Given a pipeline with DNS enabled
mockConfigHandler := config.NewMockConfigHandler()
mockConfigHandler.InitializeFunc = func() error { return nil }
mockConfigHandler.IsLoadedFunc = func() bool { return true }
mockConfigHandler.GetStringFunc = func(key string, defaultValue ...string) string {
return ""
}
mockConfigHandler.GetBoolFunc = func(key string, defaultValue ...bool) bool {
switch key {
case "vm.driver":
return "colima"
case "docker.enabled":
return true
case "dns.enabled":
return true // DNS enabled
default:
return ""
return false
}
}

setupOptions := &SetupOptions{ConfigHandler: mockConfigHandler}
pipeline, mocks := setup(t, setupOptions)

// Setup shims to allow NO_CACHE environment variable setting
mocks.Shims.Setenv = func(key, value string) error {
return nil
}

// When Execute is called
err := pipeline.Execute(context.Background())

// Then no error should be returned
if err != nil {
t.Errorf("Expected no error, got %v", err)
}

// The notification appears in stderr output (visible in test output)
})

t.Run("SkipsDNSNotificationWhenDisabled", func(t *testing.T) {
// Given a pipeline with DNS disabled
mockConfigHandler := config.NewMockConfigHandler()
mockConfigHandler.InitializeFunc = func() error { return nil }
mockConfigHandler.IsLoadedFunc = func() bool { return true }
mockConfigHandler.GetStringFunc = func(key string, defaultValue ...string) string {
return ""
}
mockConfigHandler.GetBoolFunc = func(key string, defaultValue ...bool) bool {
switch key {
case "docker.enabled":
Expand All @@ -515,22 +548,15 @@ func TestUpPipeline_Execute(t *testing.T) {
return nil
}

dnsCalled := false
mocks.NetworkManager.ConfigureDNSFunc = func() error {
dnsCalled = true
return nil
}

// When Execute is called
err := pipeline.Execute(context.Background())

// Then no error should be returned and DNS configuration should not be called
// Then no error should be returned
if err != nil {
t.Errorf("Expected no error, got %v", err)
}
if dnsCalled {
t.Error("Expected DNS configuration to not be called when DNS is disabled")
}

// No notification should appear (can verify by comparing test output)
})

// Test execution failures
Expand Down
Loading