Skip to content

Commit eb41a06

Browse files
committed
Fix PR feedback and make test steps named.
1 parent 4764bdc commit eb41a06

File tree

2 files changed

+36
-31
lines changed

2 files changed

+36
-31
lines changed

src/e2e/domain_test.go

Lines changed: 18 additions & 23 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"),
29-
Steps: []Step{
30-
func(u *Utility) {
16+
Steps: map[string]Step{
17+
"List": 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
},
36-
func(u *Utility) {
23+
"Update1": 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
},
46-
func(u *Utility) {
37+
"Update2": 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: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type CLITest struct {
3535
Create Step
3636
Get [2]Step
3737
Delete Step
38-
Steps []Step
38+
Steps map[string]Step
3939
}
4040

4141
func (ct *CLITest) Run(t *testing.T) {
@@ -47,14 +47,24 @@ func (ct *CLITest) Run(t *testing.T) {
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+
ct.Create(util)
52+
})
53+
t.Run("Get", func(t *testing.T) {
54+
ct.Get[0](util) // Should exist after create
55+
})
56+
for name, step := range ct.Steps {
57+
t.Run(name, func(t *testing.T) {
58+
step(util)
59+
})
5460
}
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
61+
t.Run("Delete", func(t *testing.T) {
62+
ct.Delete(util)
63+
})
64+
t.Run("EnsureDeleted", func(t *testing.T) {
65+
ct.Get[1](util) // Should not exist after delete
66+
})
67+
util.ID = "" // Mark as deleted so defer doesn't try again
5868
}
5969

6070
func Create(cmd string, input string) Step {

0 commit comments

Comments
 (0)