Skip to content
Open
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
34 changes: 34 additions & 0 deletions pkg/list/list_instances_upload_filter_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
Loading