compose/ecs/pkg/amazon/cloudformation_test.go
Guillaume Lours 07a57469db
Add unit tests version of migration tests instead of e2e one
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2020-08-17 21:25:53 +02:00

50 lines
1.3 KiB
Go

package amazon
import (
"fmt"
"testing"
"github.com/docker/ecs-plugin/pkg/compose"
"gotest.tools/v3/golden"
)
func TestSimpleConvert(t *testing.T) {
options := compose.ProjectOptions{
Name: t.Name(),
ConfigPaths: []string{"testdata/input/simple-single-service.yaml"},
}
result := convertResultAsString(t, options, "TestCluster")
expected := "simple/simple-cloudformation-conversion.golden"
golden.Assert(t, result, expected)
}
func TestSimpleWithOverrides(t *testing.T) {
options := compose.ProjectOptions{
Name: t.Name(),
ConfigPaths: []string{"testdata/input/simple-single-service.yaml", "testdata/input/simple-single-service-with-overrides.yaml"},
}
result := convertResultAsString(t, options, "TestCluster")
expected := "simple/simple-cloudformation-with-overrides-conversion.golden"
golden.Assert(t, result, expected)
}
func convertResultAsString(t *testing.T, options compose.ProjectOptions, clusterName string) string {
project, err := compose.ProjectFromOptions(&options)
if err != nil {
t.Error(err)
}
client, err := NewClient("", clusterName, "")
if err != nil {
t.Error(err)
}
result, err := client.Convert(project)
if err != nil {
t.Error(err)
}
resultAsJSON, err := result.JSON()
if err != nil {
t.Error(err)
}
return fmt.Sprintf("%s\n", string(resultAsJSON))
}