github.com/guilhermebr/docker@v1.4.2-0.20150428121140-67da055cebca/graph/pools_test.go (about) 1 package graph 2 3 import ( 4 "testing" 5 6 "github.com/docker/docker/pkg/reexec" 7 ) 8 9 func init() { 10 reexec.Init() 11 } 12 13 func TestPools(t *testing.T) { 14 s := &TagStore{ 15 pullingPool: make(map[string]chan struct{}), 16 pushingPool: make(map[string]chan struct{}), 17 } 18 19 if _, err := s.poolAdd("pull", "test1"); err != nil { 20 t.Fatal(err) 21 } 22 if _, err := s.poolAdd("pull", "test2"); err != nil { 23 t.Fatal(err) 24 } 25 if _, err := s.poolAdd("push", "test1"); err == nil || err.Error() != "pull test1 is already in progress" { 26 t.Fatalf("Expected `pull test1 is already in progress`") 27 } 28 if _, err := s.poolAdd("pull", "test1"); err == nil || err.Error() != "pull test1 is already in progress" { 29 t.Fatalf("Expected `pull test1 is already in progress`") 30 } 31 if _, err := s.poolAdd("wait", "test3"); err == nil || err.Error() != "Unknown pool type" { 32 t.Fatalf("Expected `Unknown pool type`") 33 } 34 if err := s.poolRemove("pull", "test2"); err != nil { 35 t.Fatal(err) 36 } 37 if err := s.poolRemove("pull", "test2"); err != nil { 38 t.Fatal(err) 39 } 40 if err := s.poolRemove("pull", "test1"); err != nil { 41 t.Fatal(err) 42 } 43 if err := s.poolRemove("push", "test1"); err != nil { 44 t.Fatal(err) 45 } 46 if err := s.poolRemove("wait", "test3"); err == nil || err.Error() != "Unknown pool type" { 47 t.Fatalf("Expected `Unknown pool type`") 48 } 49 }