Skip to content

Commit 4f853cb

Browse files
committed
PR feedback
1 parent 4764bdc commit 4f853cb

2 files changed

Lines changed: 35 additions & 28 deletions

File tree

src/e2e/domain_test.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,50 +6,45 @@ import (
66
)
77

88
func TestDomainHappyPath(t *testing.T) {
9-
createInput := `
9+
test := CLITest{
10+
Create: Create("create domain -f -", `
1011
name: "Integration Test Domain"
1112
description: "Created by integration test"
12-
`
13-
updateInput1 := `
14-
name: "Integration Test Domain Updated"
15-
description: "Updated by integration test"
16-
`
17-
updateInput2 := `
18-
name: "Integration Test Domain Updated Again"
19-
description: null
20-
`
21-
domainName := "Integration Test Domain"
22-
updatedDomainName := "Integration Test Domain Updated"
23-
updatedAgainDomainName := "Integration Test Domain Updated Again"
24-
25-
test := CLITest{
26-
Create: Create("create domain -f -", createInput),
13+
`),
2714
Get: Get("get domain"),
2815
Delete: Delete("delete domain"),
2916
Steps: []Step{
3017
func(u *Utility) {
3118
out, err := u.Run("list domain")
32-
if err != nil || !strings.Contains(out, domainName) {
19+
if err != nil || !strings.Contains(out, "Integration Test Domain") {
3320
u.Fatalf("list failed: %v\nout: %s", err, out)
3421
}
3522
},
3623
func(u *Utility) {
24+
updateInput1 := `
25+
name: "Integration Test Domain Updated"
26+
description: "Updated by integration test"
27+
`
3728
out, err := u.Run("update domain "+u.ID+" -f -", updateInput1)
3829
if err != nil {
3930
u.Fatalf("update1 failed: %v\nout: %s", err, out)
4031
}
4132
out, err = u.Run("get domain " + u.ID)
42-
if err != nil || !strings.Contains(out, updatedDomainName) || !strings.Contains(out, "Updated by integration test") {
33+
if err != nil || !strings.Contains(out, "Integration Test Domain Updated") || !strings.Contains(out, "Updated by integration test") {
4334
u.Fatalf("get after update1 failed: %v\nout: %s", err, out)
4435
}
4536
},
4637
func(u *Utility) {
38+
updateInput2 := `
39+
name: "Integration Test Domain Updated Again"
40+
description: null
41+
`
4742
out, err := u.Run("update domain "+u.ID+" -f -", updateInput2)
4843
if err != nil {
4944
u.Fatalf("update2 (unset) failed: %v\nout: %s", err, out)
5045
}
5146
out, err = u.Run("get domain " + u.ID)
52-
if err != nil || !strings.Contains(out, updatedAgainDomainName) || strings.Contains(out, "Updated by integration test") {
47+
if err != nil || !strings.Contains(out, "Integration Test Domain Updated Again") || strings.Contains(out, "Updated by integration test") {
5348
u.Fatalf("get after update2 failed (description should be unset): %v\nout: %s", err, out)
5449
}
5550
},

src/e2e/helpers.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"os"
66
"os/exec"
7+
"strconv"
78
"strings"
89
"testing"
910
)
@@ -40,21 +41,32 @@ type CLITest struct {
4041

4142
func (ct *CLITest) Run(t *testing.T) {
4243
util := &Utility{T: t}
43-
4444
defer func() {
4545
if util.ID != "" {
4646
ct.Delete(util)
4747
}
4848
}()
4949

50-
ct.Create(util)
51-
ct.Get[0](util) // Should exist after create
52-
for _, step := range ct.Steps {
53-
step(util)
50+
t.Run("Create", func(t *testing.T) {
51+
util.T = t
52+
ct.Create(util)
53+
})
54+
t.Run("Get", func(t *testing.T) {
55+
util.T = t
56+
ct.Get[0](util) // Should exist after create
57+
})
58+
for i, step := range ct.Steps {
59+
t.Run("Step "+strconv.Itoa(i), func(t *testing.T) {
60+
util.T = t
61+
step(util)
62+
})
5463
}
55-
ct.Delete(util)
56-
ct.Get[1](util) // Should not exist after delete
57-
util.ID = "" // Mark as deleted so defer doesn't try again
64+
t.Run("Delete", func(t *testing.T) {
65+
util.T = t
66+
ct.Delete(util)
67+
ct.Get[1](util) // Should not exist after delete
68+
util.ID = "" // Mark as deleted so defer doesn't try again
69+
})
5870
}
5971

6072
func Create(cmd string, input string) Step {
@@ -79,7 +91,7 @@ func Get(cmd string) [2]Step {
7991
}, func(u *Utility) {
8092
out, err := u.Run(cmd + " " + u.ID)
8193
lower := strings.ToLower(out)
82-
if err == nil || !(strings.Contains(lower, "not found") || strings.Contains(lower, "missing") || strings.Contains(lower, "gone")) {
94+
if err == nil || !(strings.Contains(lower, "not found") || strings.Contains(lower, "missing") || strings.Contains(lower, "does not exist on this account")) {
8395
u.Fatalf("expected get after delete to fail with not found, got: %v\nout: %s", err, out)
8496
}
8597
}}

0 commit comments

Comments
 (0)