(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func TestRunBuildResetsUidAndGidInContext(t *testing.T) { |
| 60 | skip.If(t, os.Getuid() != 0, "root is required to chown files") |
| 61 | t.Setenv("DOCKER_BUILDKIT", "0") |
| 62 | fakeBuild := newFakeBuild() |
| 63 | cli := test.NewFakeCli(&fakeClient{imageBuildFunc: fakeBuild.build}) |
| 64 | |
| 65 | dir := fs.NewDir(t, "test-build-context", |
| 66 | fs.WithFile("foo", "some content", fs.AsUser(65534, 65534)), |
| 67 | fs.WithFile("Dockerfile", ` |
| 68 | FROM alpine:frozen |
| 69 | COPY foo bar / |
| 70 | `), |
| 71 | ) |
| 72 | defer dir.Remove() |
| 73 | |
| 74 | options := newBuildOptions() |
| 75 | options.context = dir.Path() |
| 76 | assert.NilError(t, runBuild(context.TODO(), cli, options)) |
| 77 | |
| 78 | headers := fakeBuild.headers(t) |
| 79 | expected := []*tar.Header{ |
| 80 | {Name: "Dockerfile"}, |
| 81 | {Name: "foo"}, |
| 82 | } |
| 83 | cmpTarHeaderNameAndOwner := cmp.Comparer(func(x, y tar.Header) bool { |
| 84 | return x.Name == y.Name && x.Uid == y.Uid && x.Gid == y.Gid |
| 85 | }) |
| 86 | assert.DeepEqual(t, expected, headers, cmpTarHeaderNameAndOwner) |
| 87 | } |
| 88 | |
| 89 | func TestRunBuildDockerfileOutsideContext(t *testing.T) { |
| 90 | t.Setenv("DOCKER_BUILDKIT", "0") |
nothing calls this directly
no test coverage detected
searching dependent graphs…