buildkit/build_llb/build_graph_test.go
buildkit/build_llb/build_graph_test.goBrowse 1970 files
355 tokens
1,211 bytes
Token encoding: o200k_base
Snapshot 21a254f
← Back to SKILL.md
1package build_llb2 3import (4 "testing"5 6 "github.com/moby/buildkit/client/llb"7 specs "github.com/opencontainers/image-spec/specs-go/v1"8 "github.com/railwayapp/railpack/core/plan"9 "github.com/stretchr/testify/require"10)11 12func TestBuildGraphNoCache(t *testing.T) {13 p := &plan.BuildPlan{14 Steps: []plan.Step{15 {16 Name: "test",17 Caches: []string{"test-cache"},18 },19 },20 Caches: map[string]*plan.Cache{21 "test-cache": {22 Directory: "/root/.cache",23 },24 },25 }26 27 localState := llb.Local("context")28 cacheStore := NewBuildKitCacheStore("")29 platform := specs.Platform{OS: "linux", Architecture: "amd64"}30 31 t.Run("with NoCache=false", func(t *testing.T) {32 g, err := NewBuildGraph(p, &localState, cacheStore, "", &platform, "", false)33 require.NoError(t, err)34 require.False(t, g.NoCache)35 })36 37 t.Run("with NoCache=true", func(t *testing.T) {38 g, err := NewBuildGraph(p, &localState, cacheStore, "", &platform, "", true)39 require.NoError(t, err)40 require.True(t, g.NoCache)41 // NoCache should NOT affect if caches are enabled or not, it just affects the layer cache42 opts, err := g.getCacheMountOptions([]string{"test-cache"})43 require.NoError(t, err)44 require.Len(t, opts, 1)45 })46}47