From 8a19d4e9d072f0bbddd959984ac49c0f7ecb0964 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 17 Nov 2026 13:27:23 -0600 Subject: [PATCH] test(pro): cover upload of all component types with resolved pro.enabled Lock in that buildUploadInstances reports every instance (terraform and ansible alike) with its component type and the resolved pro.enabled state, including metadata.enabled=false overriding settings.pro.enabled=true, so Atmos Pro can show disabled instances and learn when they are disabled. Co-Authored-By: Claude Sonnet 5.5 --- pkg/list/list_instances_upload_filter_test.go | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 pkg/list/list_instances_upload_filter_test.go diff --git a/pkg/list/list_instances_upload_filter_test.go b/pkg/list/list_instances_upload_filter_test.go new file mode 100644 index 00000000000..367aa0c1903 --- /dev/null +++ b/pkg/list/list_instances_upload_filter_test.go @@ -0,0 +1,34 @@ +package list + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/cloudposse/atmos/pkg/schema" +) + +func proSettings(enabled bool) map[string]any { + return map[string]any{"pro": map[string]any{"enabled": enabled}} +} + +// Every instance is uploaded with its component type and resolved Pro state, +// regardless of type, so Atmos Pro can show it and learn when it is disabled. +func TestBuildUploadInstances_ReportsAllTypesWithEnabledState(t *testing.T) { + instances := []schema.Instance{ + {Component: "tf-off", Stack: "dev", ComponentType: "terraform", Settings: proSettings(false)}, + {Component: "ans-off", Stack: "dev", ComponentType: "ansible", Settings: proSettings(false)}, + {Component: "ans-on", Stack: "dev", ComponentType: "ansible", Settings: proSettings(true)}, + {Component: "ans-meta", Stack: "dev", ComponentType: "ansible", Settings: proSettings(true), Metadata: map[string]any{"enabled": false}}, + } + + got := buildUploadInstances(instances) + + assert.Len(t, got, len(instances)) + want := map[string]bool{"tf-off": false, "ans-off": false, "ans-on": true, "ans-meta": false} + for _, g := range got { + pro, _ := g.Settings["pro"].(map[string]any) + assert.Equal(t, want[g.Component], pro["enabled"], g.Component) + } + assert.Equal(t, "ansible", got[1].ComponentType) +}