(t *testing.T)
| 22 | ) |
| 23 | |
| 24 | func TestRunBuildDockerfileFromStdinWithCompress(t *testing.T) { |
| 25 | t.Setenv("DOCKER_BUILDKIT", "0") |
| 26 | buffer := new(bytes.Buffer) |
| 27 | fakeBuild := newFakeBuild() |
| 28 | fakeImageBuild := func(ctx context.Context, buildContext io.Reader, options client.ImageBuildOptions) (client.ImageBuildResult, error) { |
| 29 | tee := io.TeeReader(buildContext, buffer) |
| 30 | gzipReader, err := gzip.NewReader(tee) |
| 31 | assert.NilError(t, err) |
| 32 | return fakeBuild.build(ctx, gzipReader, options) |
| 33 | } |
| 34 | |
| 35 | cli := test.NewFakeCli(&fakeClient{imageBuildFunc: fakeImageBuild}) |
| 36 | dockerfile := bytes.NewBufferString(` |
| 37 | FROM alpine:frozen |
| 38 | COPY foo / |
| 39 | `) |
| 40 | cli.SetIn(streams.NewIn(io.NopCloser(dockerfile))) |
| 41 | |
| 42 | dir := fs.NewDir(t, t.Name(), |
| 43 | fs.WithFile("foo", "some content")) |
| 44 | defer dir.Remove() |
| 45 | |
| 46 | options := newBuildOptions() |
| 47 | options.compress = true |
| 48 | options.dockerfileName = "-" |
| 49 | options.context = dir.Path() |
| 50 | assert.NilError(t, runBuild(context.TODO(), cli, options)) |
| 51 | |
| 52 | expected := []string{fakeBuild.options.Dockerfile, ".dockerignore", "foo"} |
| 53 | assert.DeepEqual(t, expected, fakeBuild.filenames(t)) |
| 54 | |
| 55 | header := buffer.Bytes()[:10] |
| 56 | assert.Equal(t, compression.Gzip, compression.Detect(header)) |
| 57 | } |
| 58 | |
| 59 | func TestRunBuildResetsUidAndGidInContext(t *testing.T) { |
| 60 | skip.If(t, os.Getuid() != 0, "root is required to chown files") |
nothing calls this directly
no test coverage detected
searching dependent graphs…