mirror of
https://github.com/hanzoai/o11y-foundry.git
synced 2026-10-30 18:26:45 +00:00
Modules declare go 1.27.1 and the build images follow. go fix applied the modernizers, and new(expr) now says what the internal pointer helpers did, so they are gone; omitzero is not applied, since it changes what the JSON says. Co-authored-by: Hanzo Dev <[email protected]>
65 lines
2.3 KiB
Go
65 lines
2.3 KiB
Go
package ecsterraformcasting
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
|
|
"github.com/hanzoai/o11y-foundry/api/v1alpha1"
|
|
"github.com/hanzoai/o11y-foundry/api/v1alpha1/installation"
|
|
"github.com/hanzoai/o11y-foundry/internal/domain"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestNotEmptyAndValid(t *testing.T) {
|
|
templates := map[string]*domain.Template{
|
|
"mainTF": mainTF,
|
|
"variablesTF": variablesTF,
|
|
"moduleMainTF": moduleMainTF,
|
|
"moduleVariablesTF": moduleVariablesTF,
|
|
"moduleOutputsTF": moduleOutputsTF,
|
|
"moduleTelemetryKeeperTF": moduleTelemetryKeeperTF,
|
|
"moduleTelemetryStoreTF": moduleTelemetryStoreTF,
|
|
"moduleMigratorTF": moduleMigratorTF,
|
|
"moduleMetaStoreTF": moduleMetaStoreTF,
|
|
"moduleSignozTF": moduleSignozTF,
|
|
"moduleIngesterTF": moduleIngesterTF,
|
|
}
|
|
|
|
for name, tmpl := range templates {
|
|
assert.NotEmpty(t, tmpl, "%s should not be empty", name)
|
|
buf := bytes.NewBuffer(nil)
|
|
err := tmpl.Execute(buf, nil)
|
|
assert.NoError(t, err, "error executing %s", name)
|
|
assert.NotEmpty(t, buf.String(), "%s output should not be empty", name)
|
|
}
|
|
}
|
|
|
|
func TestTfvarsTemplateWithAnnotations(t *testing.T) {
|
|
assert.NotEmpty(t, tfarsTF)
|
|
|
|
casting := &installation.Casting{
|
|
Metadata: v1alpha1.TypeMetadata{
|
|
Name: "signoz",
|
|
Annotations: map[string]string{
|
|
"foundry.signoz.io/ecs/region": "us-east-1",
|
|
"foundry.signoz.io/ecs/cluster-id": "arn:aws:ecs:us-east-1:123456789012:cluster/test",
|
|
"foundry.signoz.io/ecs/subnet-ids": "subnet-abc123,subnet-def456",
|
|
"foundry.signoz.io/ecs/security-group-ids": "sg-abc123",
|
|
"foundry.signoz.io/ecs/vpc-id": "vpc-abc123",
|
|
"foundry.signoz.io/ecs/config-bucket": "test-configs",
|
|
"foundry.signoz.io/ecs/task-role-arn": "arn:aws:iam::123456789012:role/task",
|
|
"foundry.signoz.io/ecs/task-execution-role-arn": "arn:aws:iam::123456789012:role/exec",
|
|
"foundry.signoz.io/ecs/capacity-provider": "test-provider",
|
|
},
|
|
},
|
|
}
|
|
|
|
buf := bytes.NewBuffer(nil)
|
|
err := tfarsTF.Execute(buf, casting)
|
|
assert.NoError(t, err)
|
|
assert.NotEmpty(t, buf.String())
|
|
assert.Contains(t, buf.String(), "us-east-1")
|
|
assert.Contains(t, buf.String(), "subnet-abc123")
|
|
assert.Contains(t, buf.String(), "subnet-def456")
|
|
}
|