Files
docker-cli/components/engine/graph/pools_test.go
Aaron Lehmann d4bbf5d640 Clean up ProgressStatus
- Rename to Broadcaster

- Document exported types

- Change Wait function to just wait. Writing a message to the writer and
  adding the writer to the observers list are now handled by separate
  function calls.

- Avoid importing logrus (the condition where it was used should never
  happen, anyway).

- Make writes non-blocking

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Upstream-commit: 26c9b585042ac7dce8db83478a69fd01a4b003d7
Component: engine
2015-08-27 13:22:08 -07:00

45 lines
1.0 KiB
Go

package graph
import (
"testing"
"github.com/docker/docker/pkg/progressreader"
"github.com/docker/docker/pkg/reexec"
)
func init() {
reexec.Init()
}
func TestPools(t *testing.T) {
s := &TagStore{
pullingPool: make(map[string]*progressreader.Broadcaster),
pushingPool: make(map[string]*progressreader.Broadcaster),
}
if _, found := s.poolAdd("pull", "test1"); found {
t.Fatal("Expected pull test1 not to be in progress")
}
if _, found := s.poolAdd("pull", "test2"); found {
t.Fatal("Expected pull test2 not to be in progress")
}
if _, found := s.poolAdd("push", "test1"); !found {
t.Fatalf("Expected pull test1 to be in progress`")
}
if _, found := s.poolAdd("pull", "test1"); !found {
t.Fatalf("Expected pull test1 to be in progress`")
}
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)
}
}