2014-08-08 02:58:58 -04:00
|
|
|
package graph
|
|
|
|
|
2014-11-11 06:02:14 -05:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2015-08-25 17:17:42 -04:00
|
|
|
"github.com/docker/docker/pkg/progressreader"
|
2014-11-11 06:02:14 -05:00
|
|
|
"github.com/docker/docker/pkg/reexec"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
reexec.Init()
|
|
|
|
}
|
2014-08-08 02:58:58 -04:00
|
|
|
|
|
|
|
func TestPools(t *testing.T) {
|
|
|
|
s := &TagStore{
|
2015-08-25 17:17:42 -04:00
|
|
|
pullingPool: make(map[string]*progressreader.ProgressStatus),
|
|
|
|
pushingPool: make(map[string]*progressreader.ProgressStatus),
|
2014-08-08 02:58:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if _, err := s.poolAdd("pull", "test1"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if _, err := s.poolAdd("pull", "test2"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if _, err := s.poolAdd("push", "test1"); err == nil || err.Error() != "pull test1 is already in progress" {
|
|
|
|
t.Fatalf("Expected `pull test1 is already in progress`")
|
|
|
|
}
|
|
|
|
if _, err := s.poolAdd("pull", "test1"); err == nil || err.Error() != "pull test1 is already in progress" {
|
|
|
|
t.Fatalf("Expected `pull test1 is already in progress`")
|
|
|
|
}
|
|
|
|
if _, err := s.poolAdd("wait", "test3"); err == nil || err.Error() != "Unknown pool type" {
|
|
|
|
t.Fatalf("Expected `Unknown pool type`")
|
|
|
|
}
|
|
|
|
if err := s.poolRemove("pull", "test2"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := s.poolRemove("pull", "test2"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := s.poolRemove("pull", "test1"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := s.poolRemove("push", "test1"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := s.poolRemove("wait", "test3"); err == nil || err.Error() != "Unknown pool type" {
|
|
|
|
t.Fatalf("Expected `Unknown pool type`")
|
|
|
|
}
|
|
|
|
}
|