github.com/rightscale/docker@v1.9.1/graph/pools_test.go (about)

     1  package graph
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/docker/docker/pkg/broadcaster"
     7  	"github.com/docker/docker/pkg/reexec"
     8  )
     9  
    10  func init() {
    11  	reexec.Init()
    12  }
    13  
    14  func TestPools(t *testing.T) {
    15  	s := &TagStore{
    16  		pullingPool: make(map[string]*broadcaster.Buffered),
    17  		pushingPool: make(map[string]*broadcaster.Buffered),
    18  	}
    19  
    20  	if _, found := s.poolAdd("pull", "test1"); found {
    21  		t.Fatal("Expected pull test1 not to be in progress")
    22  	}
    23  	if _, found := s.poolAdd("pull", "test2"); found {
    24  		t.Fatal("Expected pull test2 not to be in progress")
    25  	}
    26  	if _, found := s.poolAdd("push", "test1"); !found {
    27  		t.Fatalf("Expected pull test1 to be in progress`")
    28  	}
    29  	if _, found := s.poolAdd("pull", "test1"); !found {
    30  		t.Fatalf("Expected pull test1 to be in progress`")
    31  	}
    32  	if err := s.poolRemove("pull", "test2"); err != nil {
    33  		t.Fatal(err)
    34  	}
    35  	if err := s.poolRemove("pull", "test2"); err != nil {
    36  		t.Fatal(err)
    37  	}
    38  	if err := s.poolRemove("pull", "test1"); err != nil {
    39  		t.Fatal(err)
    40  	}
    41  	if err := s.poolRemove("push", "test1"); err != nil {
    42  		t.Fatal(err)
    43  	}
    44  }