Add test for copying from scratch

Signed-off-by: Aaron Lehmann <alehmann@netflix.com>
v0.9
Aaron Lehmann 2021-06-23 13:36:36 -07:00
parent 799175fc83
commit e70f8556e5
1 changed files with 23 additions and 0 deletions

View File

@ -93,6 +93,7 @@ func TestIntegration(t *testing.T) {
testBasicRegistryCacheImportExport,
testBasicLocalCacheImportExport,
testCachedMounts,
testCopyFromScratch,
testProxyEnv,
testLocalSymlinkEscape,
testTmpfsMounts,
@ -2944,6 +2945,28 @@ func testCacheMountNoCache(t *testing.T, sb integration.Sandbox) {
require.NoError(t, err)
}
func testCopyFromScratch(t *testing.T, sb integration.Sandbox) {
requiresLinux(t)
c, err := New(sb.Context(), sb.Address())
require.NoError(t, err)
defer c.Close()
st := llb.Scratch().File(llb.Copy(llb.Scratch(), "/", "/"))
def, err := st.Marshal(sb.Context())
require.NoError(t, err)
_, err = c.Solve(sb.Context(), def, SolveOpt{}, nil)
require.NoError(t, err)
st = llb.Scratch().File(llb.Copy(llb.Scratch(), "/foo", "/"))
def, err = st.Marshal(sb.Context())
require.NoError(t, err)
_, err = c.Solve(sb.Context(), def, SolveOpt{}, nil)
require.Error(t, err)
require.Contains(t, err.Error(), "/foo: no such file or directory")
}
// containerd/containerd#2119
func testDuplicateWhiteouts(t *testing.T, sb integration.Sandbox) {
skipDockerd(t, sb)