More unit test fixes

- Fix TestGetImagesJSON when there is more than one image in the test
  repository;
- Remove an hardcoded constant use in TestGetImagesByName;
- Wait in a loop in TestKillDifferentUser;
- Use env instead of /usr/bin/env in TestEnv;
- Create a daemon user in contrib/mkimage-unittest.sh.
This commit is contained in:
Louis Opter
2013-07-01 17:19:39 -07:00
parent 6f23e39e6b
commit f03c1b8eeb
3 changed files with 19 additions and 10 deletions
+10 -3
View File
@@ -142,12 +142,13 @@ func TestGetImagesJSON(t *testing.T) {
srv := &Server{runtime: runtime}
initialImages, err := srv.Images(true, "")
// all=0
initialImages, err := srv.Images(false, "")
if err != nil {
t.Fatal(err)
}
// all=0
req, err := http.NewRequest("GET", "/images/json?all=0", nil)
if err != nil {
t.Fatal(err)
@@ -182,6 +183,12 @@ func TestGetImagesJSON(t *testing.T) {
r2 := httptest.NewRecorder()
// all=1
initialImages, err = srv.Images(true, "")
if err != nil {
t.Fatal(err)
}
req2, err := http.NewRequest("GET", "/images/json?all=true", nil)
if err != nil {
t.Fatal(err)
@@ -352,7 +359,7 @@ func TestGetImagesByName(t *testing.T) {
if err := json.Unmarshal(r.Body.Bytes(), img); err != nil {
t.Fatal(err)
}
if img.ID != GetTestImage(runtime).ID || img.Comment != "Imported from http://get.docker.io/images/busybox" {
if img.ID != unitTestImageId {
t.Errorf("Error inspecting image")
}
}