Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration test ensuring that cache paths are passed to the bootstrap correctly #2722

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
})
}