Skip to content

Commit 4d1db25

Browse files
committed
test: use shared env vars for e2e tests suites
This is intended to fix some strange behavior where one "Ordered" test writes some state that doesn't exist for the following test's run within the same describe block.
1 parent db23c3e commit 4d1db25

9 files changed

+99
-82
lines changed

tests/browse_cmds_e2e_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import (
66
. "github.com/onsi/ginkgo/v2"
77
. "github.com/onsi/gomega"
88

9-
"github.com/jahvon/flow/internal/context"
109
"github.com/jahvon/flow/tests/utils"
1110
)
1211

1312
var _ = Describe("browse e2e", Ordered, func() {
1413
var (
15-
ctx *context.Context
14+
ctx *utils.Context
1615
run *utils.CommandRunner
1716
)
1817

@@ -33,7 +32,7 @@ var _ = Describe("browse e2e", Ordered, func() {
3332
func(args []string) {
3433
stdOut := ctx.StdOut()
3534
cmdArgs := append([]string{"browse", "--list"}, args...)
36-
Expect(run.Run(ctx, cmdArgs...)).To(Succeed())
35+
Expect(run.Run(ctx.Context, cmdArgs...)).To(Succeed())
3736
out, err := readFileContent(stdOut)
3837
Expect(err).NotTo(HaveOccurred())
3938
Expect(out).To(ContainSubstring("executables:"))
@@ -50,7 +49,7 @@ var _ = Describe("browse e2e", Ordered, func() {
5049

5150
It("should show executable details by verb and name", func() {
5251
stdOut := ctx.StdOut()
53-
Expect(run.Run(ctx, "browse", "exec", "examples:simple-print")).To(Succeed())
52+
Expect(run.Run(ctx.Context, "browse", "exec", "examples:simple-print")).To(Succeed())
5453
out, err := readFileContent(stdOut)
5554
Expect(err).NotTo(HaveOccurred())
5655
Expect(out).To(ContainSubstring("name: simple-print"))

tests/cache_cmds_e2e_test.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import (
77
. "github.com/onsi/ginkgo/v2"
88
. "github.com/onsi/gomega"
99

10-
"github.com/jahvon/flow/internal/context"
1110
"github.com/jahvon/flow/tests/utils"
1211
)
1312

1413
var _ = Describe("cache e2e", Ordered, func() {
1514
var (
16-
ctx *context.Context
15+
ctx *utils.Context
1716
run *utils.CommandRunner
1817
)
1918

@@ -30,29 +29,29 @@ var _ = Describe("cache e2e", Ordered, func() {
3029
ctx.Finalize()
3130
})
3231

33-
When("setting a cache value (flow cache set)", func() {
32+
When("setting a cache value (flow cache set)", Ordered, func() {
3433
It("should set the value successfully", func() {
3534
reader, writer, err := os.Pipe()
3635
Expect(err).NotTo(HaveOccurred())
3736
_, err = writer.Write([]byte("test-value\n"))
3837
Expect(err).ToNot(HaveOccurred())
3938

4039
ctx.SetIO(reader, ctx.StdOut())
41-
Expect(run.Run(ctx, "cache", "set", "test-key")).To(Succeed())
40+
Expect(run.Run(ctx.Context, "cache", "set", "test-key")).To(Succeed())
4241
out, err := readFileContent(ctx.StdOut())
4342
Expect(err).NotTo(HaveOccurred())
4443
Expect(out).To(ContainSubstring("Key \"test-key\" set in the cache"))
4544
})
4645

4746
It("should set the value with direct argument", func() {
48-
Expect(run.Run(ctx, "cache", "set", "direct-key", "direct-value")).To(Succeed())
47+
Expect(run.Run(ctx.Context, "cache", "set", "direct-key", "direct-value")).To(Succeed())
4948
out, err := readFileContent(ctx.StdOut())
5049
Expect(err).NotTo(HaveOccurred())
5150
Expect(out).To(ContainSubstring("Key \"direct-key\" set in the cache"))
5251
})
5352

5453
It("should handle multiple arguments as single value", func() {
55-
Expect(run.Run(ctx, "cache", "set", "multi-key", "value1", "value2", "value3")).To(Succeed())
54+
Expect(run.Run(ctx.Context, "cache", "set", "multi-key", "value1", "value2", "value3")).To(Succeed())
5655
out, err := readFileContent(ctx.StdOut())
5756
Expect(err).NotTo(HaveOccurred())
5857
Expect(out).To(ContainSubstring("Key \"multi-key\" set in the cache"))
@@ -62,7 +61,7 @@ var _ = Describe("cache e2e", Ordered, func() {
6261
When("getting a cache value (flow cache get)", func() {
6362
It("should retrieve the value successfully", func() {
6463
stdOut := ctx.StdOut()
65-
Expect(run.Run(ctx, "cache", "get", "direct-key")).To(Succeed())
64+
Expect(run.Run(ctx.Context, "cache", "get", "direct-key")).To(Succeed())
6665
out, err := readFileContent(stdOut)
6766
Expect(err).NotTo(HaveOccurred())
6867
Expect(out).To(ContainSubstring("direct-value"))
@@ -72,7 +71,7 @@ var _ = Describe("cache e2e", Ordered, func() {
7271
When("listing cache entries (flow cache list)", func() {
7372
It("should list all cache entries", func() {
7473
stdOut := ctx.StdOut()
75-
Expect(run.Run(ctx, "cache", "list")).To(Succeed())
74+
Expect(run.Run(ctx.Context, "cache", "list")).To(Succeed())
7675
out, err := readFileContent(stdOut)
7776
Expect(err).NotTo(HaveOccurred())
7877
Expect(out).To(ContainSubstring("cache:"))
@@ -83,24 +82,24 @@ var _ = Describe("cache e2e", Ordered, func() {
8382

8483
When("removing a cache entry (flow cache remove)", func() {
8584
BeforeEach(func() {
86-
Expect(run.Run(ctx, "cache", "set", "remove-test-key", "remove-test-value")).To(Succeed())
85+
Expect(run.Run(ctx.Context, "cache", "set", "remove-test-key", "remove-test-value")).To(Succeed())
8786
utils.ResetTestContext(ctx, GinkgoT())
8887
})
8988

9089
It("should remove the cache entry successfully", func() {
91-
Expect(run.Run(ctx, "cache", "remove", "remove-test-key")).To(Succeed())
90+
Expect(run.Run(ctx.Context, "cache", "remove", "remove-test-key")).To(Succeed())
9291
out, err := readFileContent(ctx.StdOut())
9392
Expect(err).NotTo(HaveOccurred())
9493
Expect(out).To(ContainSubstring("Key \"remove-test-key\" removed from the cache"))
9594
})
9695

9796
It("should confirm the entry was removed", func() {
9897
// First remove the entry
99-
Expect(run.Run(ctx, "cache", "remove", "remove-test-key")).To(Succeed())
98+
Expect(run.Run(ctx.Context, "cache", "remove", "remove-test-key")).To(Succeed())
10099
utils.ResetTestContext(ctx, GinkgoT())
101100
// Then verify it's gone from the list
102101
stdOut := ctx.StdOut()
103-
Expect(run.Run(ctx, "cache", "list")).To(Succeed())
102+
Expect(run.Run(ctx.Context, "cache", "list")).To(Succeed())
104103
out, err := readFileContent(stdOut)
105104
Expect(err).NotTo(HaveOccurred())
106105
Expect(out).NotTo(ContainSubstring("remove-test-key"))
@@ -110,19 +109,19 @@ var _ = Describe("cache e2e", Ordered, func() {
110109
When("clearing all cache entries (flow cache clear)", func() {
111110
It("should clear all cache entries", func() {
112111
stdOut := ctx.StdOut()
113-
Expect(run.Run(ctx, "cache", "clear")).To(Succeed())
112+
Expect(run.Run(ctx.Context, "cache", "clear")).To(Succeed())
114113
out, err := readFileContent(stdOut)
115114
Expect(err).NotTo(HaveOccurred())
116115
Expect(out).To(ContainSubstring("Cache cleared"))
117116
})
118117

119118
It("should confirm all entries were cleared", func() {
120119
// First clear the cache
121-
Expect(run.Run(ctx, "cache", "clear")).To(Succeed())
120+
Expect(run.Run(ctx.Context, "cache", "clear")).To(Succeed())
122121
utils.ResetTestContext(ctx, GinkgoT())
123122
// Then verify the list is empty
124123
stdOut := ctx.StdOut()
125-
Expect(run.Run(ctx, "cache", "list")).To(Succeed())
124+
Expect(run.Run(ctx.Context, "cache", "list")).To(Succeed())
126125
out, err := readFileContent(stdOut)
127126
Expect(err).NotTo(HaveOccurred())
128127
Expect(out).NotTo(ContainSubstring("direct-key"))

tests/config_cmds_e2e_test.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import (
77
. "github.com/onsi/ginkgo/v2"
88
. "github.com/onsi/gomega"
99

10-
"github.com/jahvon/flow/internal/context"
1110
"github.com/jahvon/flow/tests/utils"
1211
)
1312

1413
var _ = Describe("config e2e", Ordered, func() {
1514
var (
16-
ctx *context.Context
15+
ctx *utils.Context
1716
run *utils.CommandRunner
1817
)
1918

@@ -33,7 +32,7 @@ var _ = Describe("config e2e", Ordered, func() {
3332
When("getting configuration (flow config get)", func() {
3433
It("should display configuration in yaml format", func() {
3534
stdOut := ctx.StdOut()
36-
Expect(run.Run(ctx, "config", "get", "-o", "yaml")).To(Succeed())
35+
Expect(run.Run(ctx.Context, "config", "get", "-o", "yaml")).To(Succeed())
3736
out, err := readFileContent(stdOut)
3837
Expect(err).NotTo(HaveOccurred())
3938
Expect(out).To(ContainSubstring("currentWorkspace:"))
@@ -42,7 +41,7 @@ var _ = Describe("config e2e", Ordered, func() {
4241

4342
When("setting namespace (flow config set namespace)", func() {
4443
It("should set the namespace successfully", func() {
45-
Expect(run.Run(ctx, "config", "set", "namespace", "test-namespace")).To(Succeed())
44+
Expect(run.Run(ctx.Context, "config", "set", "namespace", "test-namespace")).To(Succeed())
4645
out, err := readFileContent(ctx.StdOut())
4746
Expect(err).NotTo(HaveOccurred())
4847
Expect(out).To(ContainSubstring("Namespace set to test-namespace"))
@@ -51,14 +50,14 @@ var _ = Describe("config e2e", Ordered, func() {
5150

5251
When("setting workspace mode (flow config set workspace-mode)", func() {
5352
It("should set workspace mode to fixed", func() {
54-
Expect(run.Run(ctx, "config", "set", "workspace-mode", "fixed")).To(Succeed())
53+
Expect(run.Run(ctx.Context, "config", "set", "workspace-mode", "fixed")).To(Succeed())
5554
out, err := readFileContent(ctx.StdOut())
5655
Expect(err).NotTo(HaveOccurred())
5756
Expect(out).To(ContainSubstring("Workspace mode set to 'fixed'"))
5857
})
5958

6059
It("should set workspace mode to dynamic", func() {
61-
Expect(run.Run(ctx, "config", "set", "workspace-mode", "dynamic")).To(Succeed())
60+
Expect(run.Run(ctx.Context, "config", "set", "workspace-mode", "dynamic")).To(Succeed())
6261
out, err := readFileContent(ctx.StdOut())
6362
Expect(err).NotTo(HaveOccurred())
6463
Expect(out).To(ContainSubstring("Workspace mode set to 'dynamic'"))
@@ -67,28 +66,28 @@ var _ = Describe("config e2e", Ordered, func() {
6766

6867
When("setting log mode (flow config set log-mode)", func() {
6968
It("should set log mode to logfmt", func() {
70-
Expect(run.Run(ctx, "config", "set", "log-mode", "logfmt")).To(Succeed())
69+
Expect(run.Run(ctx.Context, "config", "set", "log-mode", "logfmt")).To(Succeed())
7170
out, err := readFileContent(ctx.StdOut())
7271
Expect(err).NotTo(HaveOccurred())
7372
Expect(out).To(ContainSubstring("Default log mode set to 'logfmt'"))
7473
})
7574

7675
It("should set log mode to json", func() {
77-
Expect(run.Run(ctx, "config", "set", "log-mode", "json")).To(Succeed())
76+
Expect(run.Run(ctx.Context, "config", "set", "log-mode", "json")).To(Succeed())
7877
out, err := readFileContent(ctx.StdOut())
7978
Expect(err).NotTo(HaveOccurred())
8079
Expect(out).To(ContainSubstring("Default log mode set to 'json'"))
8180
})
8281

8382
It("should set log mode to text", func() {
84-
Expect(run.Run(ctx, "config", "set", "log-mode", "text")).To(Succeed())
83+
Expect(run.Run(ctx.Context, "config", "set", "log-mode", "text")).To(Succeed())
8584
out, err := readFileContent(ctx.StdOut())
8685
Expect(err).NotTo(HaveOccurred())
8786
Expect(out).To(ContainSubstring("Default log mode set to 'text'"))
8887
})
8988

9089
It("should set log mode to hidden", func() {
91-
Expect(run.Run(ctx, "config", "set", "log-mode", "hidden")).To(Succeed())
90+
Expect(run.Run(ctx.Context, "config", "set", "log-mode", "hidden")).To(Succeed())
9291
out, err := readFileContent(ctx.StdOut())
9392
Expect(err).NotTo(HaveOccurred())
9493
Expect(out).To(ContainSubstring("Default log mode set to 'hidden'"))
@@ -97,14 +96,14 @@ var _ = Describe("config e2e", Ordered, func() {
9796

9897
When("setting TUI (flow config set tui)", func() {
9998
It("should enable TUI", func() {
100-
Expect(run.Run(ctx, "config", "set", "tui", "true")).To(Succeed())
99+
Expect(run.Run(ctx.Context, "config", "set", "tui", "true")).To(Succeed())
101100
out, err := readFileContent(ctx.StdOut())
102101
Expect(err).NotTo(HaveOccurred())
103102
Expect(out).To(ContainSubstring("Interactive UI enabled"))
104103
})
105104

106105
It("should disable TUI", func() {
107-
Expect(run.Run(ctx, "config", "set", "tui", "false")).To(Succeed())
106+
Expect(run.Run(ctx.Context, "config", "set", "tui", "false")).To(Succeed())
108107
out, err := readFileContent(ctx.StdOut())
109108
Expect(err).NotTo(HaveOccurred())
110109
Expect(out).To(ContainSubstring("Interactive UI disabled"))
@@ -113,14 +112,14 @@ var _ = Describe("config e2e", Ordered, func() {
113112

114113
When("setting notifications (flow config set notifications)", func() {
115114
It("should enable notifications", func() {
116-
Expect(run.Run(ctx, "config", "set", "notifications", "true")).To(Succeed())
115+
Expect(run.Run(ctx.Context, "config", "set", "notifications", "true")).To(Succeed())
117116
out, err := readFileContent(ctx.StdOut())
118117
Expect(err).NotTo(HaveOccurred())
119118
Expect(out).To(ContainSubstring("Notifications enabled"))
120119
})
121120

122121
It("should disable notifications", func() {
123-
Expect(run.Run(ctx, "config", "set", "notifications", "false")).To(Succeed())
122+
Expect(run.Run(ctx.Context, "config", "set", "notifications", "false")).To(Succeed())
124123
out, err := readFileContent(ctx.StdOut())
125124
Expect(err).NotTo(HaveOccurred())
126125
Expect(out).To(ContainSubstring("Notifications disabled"))
@@ -129,21 +128,21 @@ var _ = Describe("config e2e", Ordered, func() {
129128

130129
When("setting theme (flow config set theme)", func() {
131130
It("should set theme to light", func() {
132-
Expect(run.Run(ctx, "config", "set", "theme", "light")).To(Succeed())
131+
Expect(run.Run(ctx.Context, "config", "set", "theme", "light")).To(Succeed())
133132
out, err := readFileContent(ctx.StdOut())
134133
Expect(err).NotTo(HaveOccurred())
135134
Expect(out).To(ContainSubstring("Theme set to light"))
136135
})
137136

138137
It("should set theme to dark", func() {
139-
Expect(run.Run(ctx, "config", "set", "theme", "dark")).To(Succeed())
138+
Expect(run.Run(ctx.Context, "config", "set", "theme", "dark")).To(Succeed())
140139
out, err := readFileContent(ctx.StdOut())
141140
Expect(err).NotTo(HaveOccurred())
142141
Expect(out).To(ContainSubstring("Theme set to dark"))
143142
})
144143

145144
It("should set theme to default", func() {
146-
Expect(run.Run(ctx, "config", "set", "theme", "default")).To(Succeed())
145+
Expect(run.Run(ctx.Context, "config", "set", "theme", "default")).To(Succeed())
147146
out, err := readFileContent(ctx.StdOut())
148147
Expect(err).NotTo(HaveOccurred())
149148
Expect(out).To(ContainSubstring("Theme set to default"))
@@ -152,14 +151,14 @@ var _ = Describe("config e2e", Ordered, func() {
152151

153152
When("setting timeout (flow config set timeout)", func() {
154153
It("should set timeout to a valid duration", func() {
155-
Expect(run.Run(ctx, "config", "set", "timeout", "30s")).To(Succeed())
154+
Expect(run.Run(ctx.Context, "config", "set", "timeout", "30s")).To(Succeed())
156155
out, err := readFileContent(ctx.StdOut())
157156
Expect(err).NotTo(HaveOccurred())
158157
Expect(out).To(ContainSubstring("Default timeout set to 30s"))
159158
})
160159

161160
It("should set timeout to minutes", func() {
162-
Expect(run.Run(ctx, "config", "set", "timeout", "5m")).To(Succeed())
161+
Expect(run.Run(ctx.Context, "config", "set", "timeout", "5m")).To(Succeed())
163162
out, err := readFileContent(ctx.StdOut())
164163
Expect(err).NotTo(HaveOccurred())
165164
Expect(out).To(ContainSubstring("Default timeout set to 5m"))
@@ -174,7 +173,7 @@ var _ = Describe("config e2e", Ordered, func() {
174173
Expect(err).ToNot(HaveOccurred())
175174

176175
ctx.SetIO(reader, ctx.StdOut())
177-
Expect(run.Run(ctx, "config", "reset")).To(Succeed())
176+
Expect(run.Run(ctx.Context, "config", "reset")).To(Succeed())
178177
out, err := readFileContent(ctx.StdOut())
179178
Expect(err).NotTo(HaveOccurred())
180179
Expect(out).To(ContainSubstring("Restored flow configurations"))
@@ -187,7 +186,7 @@ var _ = Describe("config e2e", Ordered, func() {
187186
Expect(err).ToNot(HaveOccurred())
188187

189188
ctx.SetIO(reader, ctx.StdOut())
190-
Expect(run.Run(ctx, "config", "reset")).To(Succeed())
189+
Expect(run.Run(ctx.Context, "config", "reset")).To(Succeed())
191190
out, err := readFileContent(ctx.StdOut())
192191
Expect(err).NotTo(HaveOccurred())
193192
Expect(out).To(ContainSubstring("Aborting"))

tests/exec_cmd_e2e_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import (
66
. "github.com/onsi/ginkgo/v2"
77
. "github.com/onsi/gomega"
88

9-
"github.com/jahvon/flow/internal/context"
109
"github.com/jahvon/flow/tests/utils"
1110
)
1211

1312
var _ = Describe("exec e2e", func() {
1413
var (
15-
ctx *context.Context
14+
ctx *utils.Context
1615
)
1716

1817
BeforeEach(func() {
@@ -26,7 +25,7 @@ var _ = Describe("exec e2e", func() {
2625
DescribeTable("with dir example executables", func(ref string) {
2726
runner := utils.NewE2ECommandRunner()
2827
stdOut := ctx.StdOut()
29-
Expect(runner.Run(ctx, "exec", ref, "--log-level", "debug")).To(Succeed())
28+
Expect(runner.Run(ctx.Context, "exec", ref, "--log-level", "debug")).To(Succeed())
3029
Expect(readFileContent(stdOut)).To(ContainSubstring("flow completed"))
3130
},
3231
Entry("print example", "examples:simple-print"),
@@ -40,7 +39,7 @@ var _ = Describe("exec e2e", func() {
4039
runner := utils.NewE2ECommandRunner()
4140
stdOut := ctx.StdOut()
4241
Expect(runner.Run(
43-
ctx, "exec", "examples:with-params",
42+
ctx.Context, "exec", "examples:with-params",
4443
"--param", "PARAM1=value1", "--param", "PARAM2=value2", "--param", "PARAM3=value3",
4544
)).To(Succeed())
4645
out, _ := readFileContent(stdOut)

tests/logs_cmds_e2e_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import (
66
. "github.com/onsi/ginkgo/v2"
77
. "github.com/onsi/gomega"
88

9-
"github.com/jahvon/flow/internal/context"
109
"github.com/jahvon/flow/tests/utils"
1110
)
1211

1312
var _ = Describe("logs e2e", Ordered, func() {
1413
var (
15-
ctx *context.Context
14+
ctx *utils.Context
1615
run *utils.CommandRunner
1716
)
1817

@@ -32,7 +31,7 @@ var _ = Describe("logs e2e", Ordered, func() {
3231
When("viewing logs (flow logs)", func() {
3332
It("should display logs in yaml format", func() {
3433
stdOut := ctx.StdOut()
35-
Expect(run.Run(ctx, "logs")).To(Succeed())
34+
Expect(run.Run(ctx.Context, "logs")).To(Succeed())
3635
out, err := readFileContent(stdOut)
3736
Expect(err).NotTo(HaveOccurred())
3837
Expect(out).To(ContainSubstring("logs:"))
@@ -44,7 +43,7 @@ var _ = Describe("logs e2e", Ordered, func() {
4443
// TODO: test that log archiving works
4544
Skip("e2e test does not include log archiving, so this will not return any logs")
4645
stdOut := ctx.StdOut()
47-
Expect(run.Run(ctx, "logs", "--last")).To(Succeed())
46+
Expect(run.Run(ctx.Context, "logs", "--last")).To(Succeed())
4847
out, err := readFileContent(stdOut)
4948
Expect(err).NotTo(HaveOccurred())
5049
Expect(out).To(Or(ContainSubstring("msg="), ContainSubstring("No log entries")))

0 commit comments

Comments
 (0)