mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Rewrite TestBuildCopySingleFileToWorkdir to not use fixtures
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
This commit is contained in:
parent
83c5dced10
commit
d41cba6aed
2 changed files with 18 additions and 20 deletions
|
@ -1,2 +0,0 @@
|
||||||
FROM busybox
|
|
||||||
COPY test_file .
|
|
|
@ -661,28 +661,28 @@ RUN [ $(ls -l /exists | awk '{print $3":"$4}') = 'dockerio:dockerio' ]`,
|
||||||
|
|
||||||
// Issue #3960: "ADD src ." hangs - adapted for COPY
|
// Issue #3960: "ADD src ." hangs - adapted for COPY
|
||||||
func TestBuildCopySingleFileToWorkdir(t *testing.T) {
|
func TestBuildCopySingleFileToWorkdir(t *testing.T) {
|
||||||
testDirName := "SingleFileToWorkdir"
|
name := "testcopysinglefiletoworkdir"
|
||||||
sourceDirectory := filepath.Join(workingDirectory, "build_tests", "TestCopy", testDirName)
|
defer deleteImages(name)
|
||||||
buildDirectory, err := ioutil.TempDir("", "test-build-add")
|
ctx, err := fakeContext(`FROM busybox
|
||||||
defer os.RemoveAll(buildDirectory)
|
COPY test_file .`,
|
||||||
|
map[string]string{
|
||||||
err = copyWithCP(sourceDirectory, buildDirectory)
|
"test_file": "test1",
|
||||||
if err != nil {
|
})
|
||||||
t.Fatalf("failed to copy files to temporary directory: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
buildDirectory = filepath.Join(buildDirectory, testDirName)
|
|
||||||
f, err := os.OpenFile(filepath.Join(buildDirectory, "test_file"), os.O_CREATE, 0644)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
f.Close()
|
done := make(chan struct{})
|
||||||
if out, _, err := dockerCmdInDirWithTimeout(5*time.Second, buildDirectory, "build", "-t", "testcopyimg", "."); err != nil {
|
go func() {
|
||||||
t.Fatalf("build failed to complete: %s, %v", out, err)
|
if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
close(done)
|
||||||
|
}()
|
||||||
|
select {
|
||||||
|
case <-time.After(5 * time.Second):
|
||||||
|
t.Fatal("Build with adding to workdir timed out")
|
||||||
|
case <-done:
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteImages("testcopyimg")
|
|
||||||
|
|
||||||
logDone("build - copy single file to workdir")
|
logDone("build - copy single file to workdir")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue