Thanks to @tiborvass's review of another PR it was noticed that
we didn't have a testcase to make sure the cache checking for LABEL
was being done properly. This adds a test for it.
Signed-off-by: Doug Davis <dug@us.ibm.com>
... | ... |
@@ -4563,6 +4563,41 @@ func TestBuildLabels(t *testing.T) { |
4563 | 4563 |
logDone("build - label") |
4564 | 4564 |
} |
4565 | 4565 |
|
4566 |
+func TestBuildLabelsCache(t *testing.T) { |
|
4567 |
+ name := "testbuildlabelcache" |
|
4568 |
+ defer deleteImages(name) |
|
4569 |
+ |
|
4570 |
+ id1, err := buildImage(name, |
|
4571 |
+ `FROM busybox |
|
4572 |
+ LABEL Vendor=Acme`, false) |
|
4573 |
+ if err != nil { |
|
4574 |
+ t.Fatalf("Build 1 should have worked: %v", err) |
|
4575 |
+ } |
|
4576 |
+ |
|
4577 |
+ id2, err := buildImage(name, |
|
4578 |
+ `FROM busybox |
|
4579 |
+ LABEL Vendor=Acme`, true) |
|
4580 |
+ if err != nil || id1 != id2 { |
|
4581 |
+ t.Fatalf("Build 2 should have worked & used cache(%s,%s): %v", id1, id2, err) |
|
4582 |
+ } |
|
4583 |
+ |
|
4584 |
+ id2, err = buildImage(name, |
|
4585 |
+ `FROM busybox |
|
4586 |
+ LABEL Vendor=Acme1`, true) |
|
4587 |
+ if err != nil || id1 == id2 { |
|
4588 |
+ t.Fatalf("Build 2 should have worked & NOT used cache(%s,%s): %v", id1, id2, err) |
|
4589 |
+ } |
|
4590 |
+ |
|
4591 |
+ id2, err = buildImage(name, |
|
4592 |
+ `FROM busybox |
|
4593 |
+ LABEL Vendor Acme`, true) // Note: " " and "=" should be same |
|
4594 |
+ if err != nil || id1 != id2 { |
|
4595 |
+ t.Fatalf("Build 3 should have worked & used cache(%s,%s): %v", id1, id2, err) |
|
4596 |
+ } |
|
4597 |
+ |
|
4598 |
+ logDone("build - label cache") |
|
4599 |
+} |
|
4600 |
+ |
|
4566 | 4601 |
func TestBuildStderr(t *testing.T) { |
4567 | 4602 |
// This test just makes sure that no non-error output goes |
4568 | 4603 |
// to stderr |