mirror of
https://github.com/docker/compose.git
synced 2025-11-01 20:24:20 +01:00
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com> Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
50 lines
1.3 KiB
Go
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))
|
|
}
|