|
@@ -1189,8 +1189,51 @@ func TestDeleteContainers(t *testing.T) {
|
|
|
}
|
|
|
|
|
|
func TestDeleteImages(t *testing.T) {
|
|
|
- //FIXME: Implement this test
|
|
|
- t.Log("Test not implemented")
|
|
|
+ runtime, err := newTestRuntime()
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ defer nuke(runtime)
|
|
|
+
|
|
|
+ srv := &Server{runtime: runtime}
|
|
|
+
|
|
|
+ if err := srv.runtime.repositories.Set("test", "test", unitTestImageName, true); err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ images, err := srv.Images(false, "")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(images) != 2 {
|
|
|
+ t.Errorf("Excepted 2 images, %d found", len(images))
|
|
|
+ }
|
|
|
+
|
|
|
+ r := httptest.NewRecorder()
|
|
|
+ if err := deleteImages(srv, r, nil, map[string]string{"name": "test:test"}); err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+ if r.Code != http.StatusNoContent {
|
|
|
+ t.Fatalf("%d NO CONTENT expected, received %d\n", http.StatusNoContent, r.Code)
|
|
|
+ }
|
|
|
+
|
|
|
+ images, err = srv.Images(false, "")
|
|
|
+ if err != nil {
|
|
|
+ t.Fatal(err)
|
|
|
+ }
|
|
|
+
|
|
|
+ if len(images) != 1 {
|
|
|
+ t.Errorf("Excepted 1 image, %d found", len(images))
|
|
|
+ }
|
|
|
+
|
|
|
+ /* if c := runtime.Get(container.Id); c != nil {
|
|
|
+ t.Fatalf("The container as not been deleted")
|
|
|
+ }
|
|
|
+
|
|
|
+ if _, err := os.Stat(path.Join(container.rwPath(), "test")); err == nil {
|
|
|
+ t.Fatalf("The test file has not been deleted")
|
|
|
+ } */
|
|
|
}
|
|
|
|
|
|
// Mocked types for tests
|