Skip to content

Commit

Permalink
Merge pull request #2722 from buildkite/cache-paths-integration-test
Browse files Browse the repository at this point in the history
Add integration test ensuring that cache paths are passed to the bootstrap correctly
  • Loading branch information
matthewborden committed Apr 10, 2024
2 parents 79689e2 + b55643a commit cb66155
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions agent/integration/job_environment_integration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package integration

import (
"context"
"testing"

"github.com/buildkite/agent/v3/agent"
"github.com/buildkite/agent/v3/api"
"github.com/buildkite/bintest/v3"
"github.com/buildkite/go-pipeline"
)

func TestWhenCachePathsSetInJobStep_CachePathsEnvVarIsSet(t *testing.T) {
t.Parallel()

ctx := context.Background()
job := &api.Job{
ID: "my-job-id",
ChunksMaxSizeBytes: 1024,
Step: pipeline.CommandStep{
Cache: &pipeline.Cache{
Paths: []string{"foo", "bar"},
},
},
}

mb := mockBootstrap(t)
defer mb.CheckAndClose(t)

mb.Expect().Once().AndExitWith(0).AndCallFunc(func(c *bintest.Call) {
if got, want := c.GetEnv("BUILDKITE_AGENT_CACHE_PATHS"), "foo,bar"; got != want {
t.Errorf("c.GetEnv(BUILDKITE_AGENT_CACHE_PATHS) = %q, want %q", got, want)
}
c.Exit(0)
})

// create a mock agent API
e := createTestAgentEndpoint()
server := e.server("my-job-id")
defer server.Close()

runJob(t, ctx, testRunJobConfig{
job: job,
server: server,
agentCfg: agent.AgentConfiguration{},
mockBootstrap: mb,
})
}

0 comments on commit cb66155

Please sign in to comment.