When the unit testing is not there, issue an error and offer a solution instead of automagically downloading the image
This commit is contained in:
parent
73fc7c4307
commit
b5768f30eb
|
@ -1,11 +1,9 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -17,25 +15,12 @@ func init() {
|
||||||
SysInit()
|
SysInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the unit test image is there, download otherwise
|
// Make sure the unit test image is there
|
||||||
_, err := os.Stat(testLayerPath)
|
if _, err := os.Stat(testLayerPath); err != nil {
|
||||||
// The image is already there
|
if !os.IsNotExist(err) {
|
||||||
if err == nil {
|
panic(err)
|
||||||
return
|
}
|
||||||
}
|
log.Fatalf("Unit test base image not found. Please fix the problem by running \"debootstrap --arch=amd64 quantal %v\"", testLayerPath)
|
||||||
// Otherwise, we'll have to fetch it
|
|
||||||
if !os.IsNotExist(err) {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
log.Printf("Test image not found. Downloading and extracting for the first time.")
|
|
||||||
if err := os.MkdirAll(testLayerPath, 0755); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
cmd := exec.Command("sh", "-c", fmt.Sprintf("wget https://s3.amazonaws.com/docker.io/images/base -O - | tar -jx -C %v/", testLayerPath))
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stdout
|
|
||||||
if err := cmd.Run(); err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue