Skip to content
This repository was archived by the owner on Nov 19, 2025. It is now read-only.

Commit 9f9dbe4

Browse files
committed
Upgrade testify to 1.3.0 and create Compose file as a temp file
1 parent ebe9a86 commit 9f9dbe4

File tree

16 files changed

+1544
-273
lines changed

16 files changed

+1544
-273
lines changed

ecs-cli/Gopkg.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ecs-cli/Gopkg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
[[constraint]]
6767
name = "github.com/stretchr/testify"
68-
version = "=1.2.1"
68+
version = "=1.3.0"
6969

7070
[[constraint]]
7171
name = "github.com/urfave/cli"

ecs-cli/integ/cmd/compose.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ import (
2929

3030
// A Project is the configuration needed to create an ECS Service.
3131
type Project struct {
32-
Name string
33-
ConfigName string
32+
Name string
33+
ComposeFileName string
34+
ECSParamsFileName string
35+
ConfigName string
3436
}
3537

3638
// NewProject creates a new Project for an ECS Service.
@@ -46,11 +48,14 @@ func TestServiceUp(t *testing.T, p *Project) {
4648
// Given
4749
args := []string{
4850
"compose",
51+
"--file",
52+
p.ComposeFileName,
53+
"--ecs-params",
54+
p.ECSParamsFileName,
4955
"--project-name",
5056
p.Name,
5157
"service",
5258
"up",
53-
"--create-log-groups",
5459
"--cluster-config",
5560
p.ConfigName,
5661
}
@@ -85,6 +90,10 @@ func TestServiceScale(t *testing.T, p *Project, scale int) {
8590
// Given
8691
args := []string{
8792
"compose",
93+
"--file",
94+
p.ComposeFileName,
95+
"--ecs-params",
96+
p.ECSParamsFileName,
8897
"--project-name",
8998
p.Name,
9099
"service",
@@ -114,6 +123,10 @@ func TestServiceDown(t *testing.T, p *Project) {
114123
// Given
115124
args := []string{
116125
"compose",
126+
"--file",
127+
p.ComposeFileName,
128+
"--ecs-params",
129+
p.ECSParamsFileName,
117130
"--project-name",
118131
p.Name,
119132
"service",
@@ -142,6 +155,10 @@ func testServiceHasAllRunningContainers(t *testing.T, p *Project, wantedNumOfCon
142155
// Given
143156
args := []string{
144157
"compose",
158+
"--file",
159+
p.ComposeFileName,
160+
"--ecs-params",
161+
p.ECSParamsFileName,
145162
"--project-name",
146163
p.Name,
147164
"service",

ecs-cli/integ/e2e/fargate_service_test.go

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ func TestCreateClusterWithFargateService(t *testing.T) {
3434
vpc := cmd.TestUp(t, conf)
3535

3636
// Create the files for a task definition
37-
createComposeFile(t)
38-
createECSParamsFile(t, vpc.Subnets)
37+
project := cmd.NewProject("e2e-fargate-test-service", conf.ConfigName)
38+
project.ComposeFileName = createComposeFile(t)
39+
project.ECSParamsFileName = createECSParamsFile(t, vpc.Subnets)
40+
defer os.Remove(project.ComposeFileName)
41+
defer os.Remove(project.ECSParamsFileName)
3942

4043
// Create a new service
41-
project := cmd.NewProject("e2e-fargate-test-service", conf.ConfigName)
4244
cmd.TestServiceUp(t, project)
4345
cmd.TestServicePs(t, project, 1)
4446

@@ -53,7 +55,7 @@ func TestCreateClusterWithFargateService(t *testing.T) {
5355
cmd.TestDown(t, conf)
5456
}
5557

56-
func createComposeFile(t *testing.T) {
58+
func createComposeFile(t *testing.T) string {
5759
content := `
5860
version: '3'
5961
services:
@@ -67,11 +69,21 @@ services:
6769
awslogs-group: tutorial
6870
awslogs-region: us-east-1
6971
awslogs-stream-prefix: wordpress`
70-
err := ioutil.WriteFile("./docker-compose.yml", []byte(content), os.ModePerm)
72+
73+
tmpfile, err := ioutil.TempFile("", "docker-compose-*.yml")
7174
require.NoError(t, err, "Failed to create docker-compose.yml")
75+
76+
_, err = tmpfile.Write([]byte(content))
77+
require.NoErrorf(t, err, "Failed to write to %s", tmpfile.Name())
78+
79+
err = tmpfile.Close()
80+
require.NoErrorf(t, err, "Failed to close %s", tmpfile.Name())
81+
82+
t.Logf("Created %s successfully", tmpfile.Name())
83+
return tmpfile.Name()
7284
}
7385

74-
func createECSParamsFile(t *testing.T, subnets []string) {
86+
func createECSParamsFile(t *testing.T, subnets []string) string {
7587
content := `
7688
version: 1
7789
task_definition:
@@ -89,6 +101,15 @@ run_params:
89101
content += `
90102
- "` + subnet + `"`
91103
}
92-
err := ioutil.WriteFile("./ecs-params.yml", []byte(content), os.ModePerm)
104+
tmpfile, err := ioutil.TempFile("", "ecs-params-*.yml")
93105
require.NoError(t, err, "Failed to create ecs-params.yml")
106+
107+
_, err = tmpfile.Write([]byte(content))
108+
require.NoErrorf(t, err, "Failed to write to %s", tmpfile.Name())
109+
110+
err = tmpfile.Close()
111+
require.NoErrorf(t, err, "Failed to close %s", tmpfile.Name())
112+
113+
t.Logf("Created %s successfully", tmpfile.Name())
114+
return tmpfile.Name()
94115
}

ecs-cli/vendor/github.com/stretchr/testify/LICENSE

Lines changed: 17 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)