Docker-DCO-1.1-Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com> (github: LK4D4)
| ... | ... |
@@ -1256,3 +1256,20 @@ func TestBuildInheritance(t *testing.T) {
|
| 1256 | 1256 |
} |
| 1257 | 1257 |
logDone("build - inheritance")
|
| 1258 | 1258 |
} |
| 1259 |
+ |
|
| 1260 |
+func TestBuildFails(t *testing.T) {
|
|
| 1261 |
+ name := "testbuildfails" |
|
| 1262 |
+ defer deleteImages(name) |
|
| 1263 |
+ _, err := buildImage(name, |
|
| 1264 |
+ `FROM busybox |
|
| 1265 |
+ RUN sh -c "exit 23"`, |
|
| 1266 |
+ true) |
|
| 1267 |
+ if err != nil {
|
|
| 1268 |
+ if !strings.Contains(err.Error(), "returned a non-zero code: 23") {
|
|
| 1269 |
+ t.Fatalf("Wrong error %v, must be about non-zero code 23", err)
|
|
| 1270 |
+ } |
|
| 1271 |
+ } else {
|
|
| 1272 |
+ t.Fatal("Error must not be nil")
|
|
| 1273 |
+ } |
|
| 1274 |
+ logDone("build - fails")
|
|
| 1275 |
+} |
| ... | ... |
@@ -413,26 +413,6 @@ func buildImage(context testContextTemplate, t *testing.T, eng *engine.Engine, u |
| 413 | 413 |
return image, err |
| 414 | 414 |
} |
| 415 | 415 |
|
| 416 |
-func TestBuildFails(t *testing.T) {
|
|
| 417 |
- _, err := buildImage(testContextTemplate{`
|
|
| 418 |
- from {IMAGE}
|
|
| 419 |
- run sh -c "exit 23" |
|
| 420 |
- `, |
|
| 421 |
- nil, nil}, t, nil, true) |
|
| 422 |
- |
|
| 423 |
- if err == nil {
|
|
| 424 |
- t.Fatal("Error should not be nil")
|
|
| 425 |
- } |
|
| 426 |
- |
|
| 427 |
- sterr, ok := err.(*utils.JSONError) |
|
| 428 |
- if !ok {
|
|
| 429 |
- t.Fatalf("Error should be utils.JSONError")
|
|
| 430 |
- } |
|
| 431 |
- if sterr.Code != 23 {
|
|
| 432 |
- t.Fatalf("StatusCode %d unexpected, should be 23", sterr.Code)
|
|
| 433 |
- } |
|
| 434 |
-} |
|
| 435 |
- |
|
| 436 | 416 |
func TestBuildFailsDockerfileEmpty(t *testing.T) {
|
| 437 | 417 |
_, err := buildImage(testContextTemplate{``, nil, nil}, t, nil, true)
|
| 438 | 418 |
|