mirror of
https://github.com/psviderski/uncloud.git
synced 2026-11-10 12:44:16 +00:00
fix(plan): make stop operation formatting consistent and do not count it as removal in summary
This commit is contained in:
@@ -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()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user