check_test.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package main
  2. import (
  3. "testing"
  4. "github.com/go-check/check"
  5. )
  6. func Test(t *testing.T) {
  7. check.TestingT(t)
  8. }
  9. func init() {
  10. check.Suite(&DockerSuite{})
  11. }
  12. type DockerSuite struct {
  13. }
  14. func (s *DockerSuite) TearDownTest(c *check.C) {
  15. deleteAllContainers()
  16. deleteAllImages()
  17. deleteAllVolumes()
  18. }
  19. func init() {
  20. check.Suite(&DockerRegistrySuite{
  21. ds: &DockerSuite{},
  22. })
  23. }
  24. type DockerRegistrySuite struct {
  25. ds *DockerSuite
  26. reg *testRegistryV2
  27. d *Daemon
  28. }
  29. func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
  30. testRequires(c, DaemonIsLinux)
  31. s.reg = setupRegistry(c)
  32. s.d = NewDaemon(c)
  33. }
  34. func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
  35. if s.reg != nil {
  36. s.reg.Close()
  37. }
  38. if s.ds != nil {
  39. s.ds.TearDownTest(c)
  40. }
  41. s.d.Stop()
  42. }
  43. func init() {
  44. check.Suite(&DockerDaemonSuite{
  45. ds: &DockerSuite{},
  46. })
  47. }
  48. type DockerDaemonSuite struct {
  49. ds *DockerSuite
  50. d *Daemon
  51. }
  52. func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
  53. testRequires(c, DaemonIsLinux)
  54. s.d = NewDaemon(c)
  55. }
  56. func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
  57. testRequires(c, DaemonIsLinux)
  58. s.d.Stop()
  59. s.ds.TearDownTest(c)
  60. }
  61. func init() {
  62. check.Suite(&DockerTrustSuite{
  63. ds: &DockerSuite{},
  64. })
  65. }
  66. type DockerTrustSuite struct {
  67. ds *DockerSuite
  68. reg *testRegistryV2
  69. not *testNotary
  70. }
  71. func (s *DockerTrustSuite) SetUpTest(c *check.C) {
  72. s.reg = setupRegistry(c)
  73. s.not = setupNotary(c)
  74. }
  75. func (s *DockerTrustSuite) TearDownTest(c *check.C) {
  76. s.reg.Close()
  77. s.not.Close()
  78. s.ds.TearDownTest(c)
  79. }