check_test.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package main
  2. import (
  3. "fmt"
  4. "testing"
  5. "github.com/docker/docker/pkg/reexec"
  6. "github.com/go-check/check"
  7. )
  8. func Test(t *testing.T) {
  9. reexec.Init() // This is required for external graphdriver tests
  10. if !isLocalDaemon {
  11. fmt.Println("INFO: Testing against a remote daemon")
  12. } else {
  13. fmt.Println("INFO: Testing against a local daemon")
  14. }
  15. check.TestingT(t)
  16. }
  17. func init() {
  18. check.Suite(&DockerSuite{})
  19. }
  20. type DockerSuite struct {
  21. }
  22. func (s *DockerSuite) TearDownTest(c *check.C) {
  23. deleteAllContainers()
  24. deleteAllImages()
  25. deleteAllVolumes()
  26. deleteAllNetworks()
  27. }
  28. func init() {
  29. check.Suite(&DockerRegistrySuite{
  30. ds: &DockerSuite{},
  31. })
  32. }
  33. type DockerRegistrySuite struct {
  34. ds *DockerSuite
  35. reg *testRegistryV2
  36. d *Daemon
  37. }
  38. func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
  39. testRequires(c, DaemonIsLinux)
  40. s.reg = setupRegistry(c, false)
  41. s.d = NewDaemon(c)
  42. }
  43. func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
  44. if s.reg != nil {
  45. s.reg.Close()
  46. }
  47. if s.ds != nil {
  48. s.ds.TearDownTest(c)
  49. }
  50. s.d.Stop()
  51. }
  52. func init() {
  53. check.Suite(&DockerSchema1RegistrySuite{
  54. ds: &DockerSuite{},
  55. })
  56. }
  57. type DockerSchema1RegistrySuite struct {
  58. ds *DockerSuite
  59. reg *testRegistryV2
  60. d *Daemon
  61. }
  62. func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) {
  63. testRequires(c, DaemonIsLinux)
  64. s.reg = setupRegistry(c, true)
  65. s.d = NewDaemon(c)
  66. }
  67. func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) {
  68. if s.reg != nil {
  69. s.reg.Close()
  70. }
  71. if s.ds != nil {
  72. s.ds.TearDownTest(c)
  73. }
  74. s.d.Stop()
  75. }
  76. func init() {
  77. check.Suite(&DockerDaemonSuite{
  78. ds: &DockerSuite{},
  79. })
  80. }
  81. type DockerDaemonSuite struct {
  82. ds *DockerSuite
  83. d *Daemon
  84. }
  85. func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
  86. testRequires(c, DaemonIsLinux)
  87. s.d = NewDaemon(c)
  88. }
  89. func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
  90. testRequires(c, DaemonIsLinux)
  91. s.d.Stop()
  92. s.ds.TearDownTest(c)
  93. }
  94. func init() {
  95. check.Suite(&DockerTrustSuite{
  96. ds: &DockerSuite{},
  97. })
  98. }
  99. type DockerTrustSuite struct {
  100. ds *DockerSuite
  101. reg *testRegistryV2
  102. not *testNotary
  103. }
  104. func (s *DockerTrustSuite) SetUpTest(c *check.C) {
  105. s.reg = setupRegistry(c, false)
  106. s.not = setupNotary(c)
  107. }
  108. func (s *DockerTrustSuite) TearDownTest(c *check.C) {
  109. s.reg.Close()
  110. s.not.Close()
  111. s.ds.TearDownTest(c)
  112. }