github.com/ncdc/docker@v0.10.1-0.20160129113957-6c6729ef5b74/integration-cli/check_test.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/docker/docker/pkg/reexec" 8 "github.com/go-check/check" 9 ) 10 11 func Test(t *testing.T) { 12 reexec.Init() // This is required for external graphdriver tests 13 14 if !isLocalDaemon { 15 fmt.Println("INFO: Testing against a remote daemon") 16 } else { 17 fmt.Println("INFO: Testing against a local daemon") 18 } 19 20 check.TestingT(t) 21 } 22 23 func init() { 24 check.Suite(&DockerSuite{}) 25 } 26 27 type DockerSuite struct { 28 } 29 30 func (s *DockerSuite) TearDownTest(c *check.C) { 31 unpauseAllContainers() 32 deleteAllContainers() 33 deleteAllImages() 34 deleteAllVolumes() 35 deleteAllNetworks() 36 } 37 38 func init() { 39 check.Suite(&DockerRegistrySuite{ 40 ds: &DockerSuite{}, 41 }) 42 } 43 44 type DockerRegistrySuite struct { 45 ds *DockerSuite 46 reg *testRegistryV2 47 d *Daemon 48 } 49 50 func (s *DockerRegistrySuite) SetUpTest(c *check.C) { 51 testRequires(c, DaemonIsLinux) 52 s.reg = setupRegistry(c, false, false) 53 s.d = NewDaemon(c) 54 } 55 56 func (s *DockerRegistrySuite) TearDownTest(c *check.C) { 57 if s.reg != nil { 58 s.reg.Close() 59 } 60 if s.d != nil { 61 s.d.Stop() 62 } 63 s.ds.TearDownTest(c) 64 } 65 66 func init() { 67 check.Suite(&DockerSchema1RegistrySuite{ 68 ds: &DockerSuite{}, 69 }) 70 } 71 72 type DockerSchema1RegistrySuite struct { 73 ds *DockerSuite 74 reg *testRegistryV2 75 d *Daemon 76 } 77 78 func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) { 79 testRequires(c, DaemonIsLinux) 80 s.reg = setupRegistry(c, true, false) 81 s.d = NewDaemon(c) 82 } 83 84 func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) { 85 if s.reg != nil { 86 s.reg.Close() 87 } 88 if s.d != nil { 89 s.d.Stop() 90 } 91 s.ds.TearDownTest(c) 92 } 93 94 func init() { 95 check.Suite(&DockerRegistryAuthSuite{ 96 ds: &DockerSuite{}, 97 }) 98 } 99 100 type DockerRegistryAuthSuite struct { 101 ds *DockerSuite 102 reg *testRegistryV2 103 d *Daemon 104 } 105 106 func (s *DockerRegistryAuthSuite) SetUpTest(c *check.C) { 107 testRequires(c, DaemonIsLinux) 108 s.reg = setupRegistry(c, false, true) 109 s.d = NewDaemon(c) 110 } 111 112 func (s *DockerRegistryAuthSuite) TearDownTest(c *check.C) { 113 if s.reg != nil { 114 out, err := s.d.Cmd("logout", privateRegistryURL) 115 c.Assert(err, check.IsNil, check.Commentf(out)) 116 s.reg.Close() 117 } 118 if s.d != nil { 119 s.d.Stop() 120 } 121 s.ds.TearDownTest(c) 122 } 123 124 func init() { 125 check.Suite(&DockerDaemonSuite{ 126 ds: &DockerSuite{}, 127 }) 128 } 129 130 type DockerDaemonSuite struct { 131 ds *DockerSuite 132 d *Daemon 133 } 134 135 func (s *DockerDaemonSuite) SetUpTest(c *check.C) { 136 testRequires(c, DaemonIsLinux) 137 s.d = NewDaemon(c) 138 } 139 140 func (s *DockerDaemonSuite) TearDownTest(c *check.C) { 141 testRequires(c, DaemonIsLinux) 142 if s.d != nil { 143 s.d.Stop() 144 } 145 s.ds.TearDownTest(c) 146 } 147 148 func init() { 149 check.Suite(&DockerTrustSuite{ 150 ds: &DockerSuite{}, 151 }) 152 } 153 154 type DockerTrustSuite struct { 155 ds *DockerSuite 156 reg *testRegistryV2 157 not *testNotary 158 } 159 160 func (s *DockerTrustSuite) SetUpTest(c *check.C) { 161 s.reg = setupRegistry(c, false, false) 162 s.not = setupNotary(c) 163 } 164 165 func (s *DockerTrustSuite) TearDownTest(c *check.C) { 166 if s.reg != nil { 167 s.reg.Close() 168 } 169 if s.not != nil { 170 s.not.Close() 171 } 172 s.ds.TearDownTest(c) 173 }