Skip to content

Commit b55643a

Browse files
committed
Add integration test ensuring that cache paths are passed to the bootstrap correctly
1 parent 9686917 commit b55643a

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package integration
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/buildkite/agent/v3/agent"
8+
"github.com/buildkite/agent/v3/api"
9+
"github.com/buildkite/bintest/v3"
10+
"github.com/buildkite/go-pipeline"
11+
)
12+
13+
func TestWhenCachePathsSetInJobStep_CachePathsEnvVarIsSet(t *testing.T) {
14+
t.Parallel()
15+
16+
ctx := context.Background()
17+
job := &api.Job{
18+
ID: "my-job-id",
19+
ChunksMaxSizeBytes: 1024,
20+
Step: pipeline.CommandStep{
21+
Cache: &pipeline.Cache{
22+
Paths: []string{"foo", "bar"},
23+
},
24+
},
25+
}
26+
27+
mb := mockBootstrap(t)
28+
defer mb.CheckAndClose(t)
29+
30+
mb.Expect().Once().AndExitWith(0).AndCallFunc(func(c *bintest.Call) {
31+
if got, want := c.GetEnv("BUILDKITE_AGENT_CACHE_PATHS"), "foo,bar"; got != want {
32+
t.Errorf("c.GetEnv(BUILDKITE_AGENT_CACHE_PATHS) = %q, want %q", got, want)
33+
}
34+
c.Exit(0)
35+
})
36+
37+
// create a mock agent API
38+
e := createTestAgentEndpoint()
39+
server := e.server("my-job-id")
40+
defer server.Close()
41+
42+
runJob(t, ctx, testRunJobConfig{
43+
job: job,
44+
server: server,
45+
agentCfg: agent.AgentConfiguration{},
46+
mockBootstrap: mb,
47+
})
48+
}

0 commit comments

Comments
 (0)