Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
| ... | ... |
@@ -207,6 +207,33 @@ func TestBuildWithInaccessibleFilesInContext(t *testing.T) {
|
| 207 | 207 |
logDone("build - ADD from context with accessible links must work")
|
| 208 | 208 |
} |
| 209 | 209 |
|
| 210 |
+func TestBuildForceRm(t *testing.T) {
|
|
| 211 |
+ containerCountBefore, err := getContainerCount() |
|
| 212 |
+ if err != nil {
|
|
| 213 |
+ t.Fatalf("failed to get the container count: %s", err)
|
|
| 214 |
+ } |
|
| 215 |
+ |
|
| 216 |
+ buildDirectory := filepath.Join(workingDirectory, "build_tests", "TestBuildForceRm") |
|
| 217 |
+ buildCmd := exec.Command(dockerBinary, "build", "--force-rm", ".") |
|
| 218 |
+ buildCmd.Dir = buildDirectory |
|
| 219 |
+ _, exitCode, err := runCommandWithOutput(buildCmd) |
|
| 220 |
+ |
|
| 221 |
+ if err == nil || exitCode == 0 {
|
|
| 222 |
+ t.Fatal("failed to build the image")
|
|
| 223 |
+ } |
|
| 224 |
+ |
|
| 225 |
+ containerCountAfter, err := getContainerCount() |
|
| 226 |
+ if err != nil {
|
|
| 227 |
+ t.Fatalf("failed to get the container count: %s", err)
|
|
| 228 |
+ } |
|
| 229 |
+ |
|
| 230 |
+ if containerCountBefore != containerCountAfter {
|
|
| 231 |
+ t.Fatalf("--force-rm shouldn't have left containers behind")
|
|
| 232 |
+ } |
|
| 233 |
+ |
|
| 234 |
+ logDone("build - ensure --force-rm doesn't leave containers behind")
|
|
| 235 |
+} |
|
| 236 |
+ |
|
| 210 | 237 |
// TODO: TestCaching |
| 211 | 238 |
|
| 212 | 239 |
// TODO: TestADDCacheInvalidation |