| ... | ... |
@@ -120,6 +120,29 @@ func TestMount(t *testing.T) {
|
| 120 | 120 |
}() |
| 121 | 121 |
} |
| 122 | 122 |
|
| 123 |
+// Test that an image can be deleted by its shorthand prefix |
|
| 124 |
+func TestDeletePrefix(t *testing.T) {
|
|
| 125 |
+ graph := tempGraph(t) |
|
| 126 |
+ defer os.RemoveAll(graph.Root) |
|
| 127 |
+ img := createTestImage(graph, t) |
|
| 128 |
+ if err := graph.Delete(TruncateId(img.Id)); err != nil {
|
|
| 129 |
+ t.Fatal(err) |
|
| 130 |
+ } |
|
| 131 |
+ assertNImages(graph, t, 0) |
|
| 132 |
+} |
|
| 133 |
+ |
|
| 134 |
+func createTestImage(graph *Graph, t *testing.T) *Image {
|
|
| 135 |
+ archive, err := fakeTar() |
|
| 136 |
+ if err != nil {
|
|
| 137 |
+ t.Fatal(err) |
|
| 138 |
+ } |
|
| 139 |
+ img, err := graph.Create(archive, nil, "Test image") |
|
| 140 |
+ if err != nil {
|
|
| 141 |
+ t.Fatal(err) |
|
| 142 |
+ } |
|
| 143 |
+ return img |
|
| 144 |
+} |
|
| 145 |
+ |
|
| 123 | 146 |
func TestDelete(t *testing.T) {
|
| 124 | 147 |
graph := tempGraph(t) |
| 125 | 148 |
defer os.RemoveAll(graph.Root) |