func newTestEngine(t *testing.T) *Engine { tmp, err := utils.TestDirectory("") if err != nil { t.Fatal(err) } eng, err := New(tmp) if err != nil { t.Fatal(err) } return eng }
func TestLookupImage(t *testing.T) { tmp, err := utils.TestDirectory("") if err != nil { t.Fatal(err) } defer os.RemoveAll(tmp) store := mkTestTagStore(tmp, t) defer store.graph.driver.Cleanup() if img, err := store.LookupImage(testImageName); err != nil { t.Fatal(err) } else if img == nil { t.Errorf("Expected 1 image, none found") } if img, err := store.LookupImage(testImageName + ":" + DEFAULTTAG); err != nil { t.Fatal(err) } else if img == nil { t.Errorf("Expected 1 image, none found") } if img, err := store.LookupImage(testImageName + ":" + "fail"); err == nil { t.Errorf("Expected error, none found") } else if img != nil { t.Errorf("Expected 0 image, 1 found") } if img, err := store.LookupImage("fail:fail"); err == nil { t.Errorf("Expected error, none found") } else if img != nil { t.Errorf("Expected 0 image, 1 found") } if img, err := store.LookupImage(testImageID); err != nil { t.Fatal(err) } else if img == nil { t.Errorf("Expected 1 image, none found") } if img, err := store.LookupImage(testImageName + ":" + testImageID); err != nil { t.Fatal(err) } else if img == nil { t.Errorf("Expected 1 image, none found") } }
func newTestDirectory(templateDir string) (dir string, err error) { return utils.TestDirectory(templateDir) }