fix(plan): make stop operation formatting consistent and do not count it as removal in summary

This commit is contained in:
Pasha Sviderski
2026-11-03 12:54:57 +10:00
parent ff6ac45e1e
commit 6c7ddeb82f
8 changed files with 48 additions and 5 deletions
+17
View File
@@ -4,6 +4,7 @@ import (
"testing"
"github.com/charmbracelet/x/ansi"
"github.com/psviderski/uncloud/pkg/api"
"github.com/psviderski/uncloud/pkg/client/deploy"
"github.com/psviderski/uncloud/pkg/client/operation"
"github.com/stretchr/testify/assert"
@@ -28,3 +29,19 @@ func TestPlan_FormatSummary(t *testing.T) {
assert.Equal(t, "1 create · 2 update (in place) · 1 remove · across 3 machines", ansi.Strip(plan.formatSummary()))
}
func TestPlan_FormatSummary_StopOperationsNotCounted(t *testing.T) {
t.Parallel()
svc := &deploy.ServicePlan{}
svc.Operations = []operation.Operation{
&operation.StopContainerOperation{MachineID: "m-1"},
&operation.StopContainerOperation{MachineID: "m-1"},
&operation.ReplaceContainerOperation{MachineID: "m-1", Order: api.UpdateOrderStopFirst},
&operation.RemoveContainerOperation{MachineID: "m-1"},
}
plan := &Plan{Services: []*deploy.ServicePlan{svc}}
// Stop operations aren't counted because a later operation in the plan removes the stopped container.
assert.Equal(t, "1 replace (stop-first) · 1 remove · across 1 machine", ansi.Strip(plan.formatSummary()))
}