check_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. }
  27. func init() {
  28. check.Suite(&DockerRegistrySuite{
  29. ds: &DockerSuite{},
  30. })
  31. }
  32. type DockerRegistrySuite struct {
  33. ds *DockerSuite
  34. reg *testRegistryV2
  35. d *Daemon
  36. }
  37. func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
  38. testRequires(c, DaemonIsLinux)
  39. s.reg = setupRegistry(c)
  40. s.d = NewDaemon(c)
  41. }
  42. func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
  43. if s.reg != nil {
  44. s.reg.Close()
  45. }
  46. if s.ds != nil {
  47. s.ds.TearDownTest(c)
  48. }
  49. s.d.Stop()
  50. }
  51. func init() {
  52. check.Suite(&DockerDaemonSuite{
  53. ds: &DockerSuite{},
  54. })
  55. }
  56. type DockerDaemonSuite struct {
  57. ds *DockerSuite
  58. d *Daemon
  59. }
  60. func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
  61. testRequires(c, DaemonIsLinux)
  62. s.d = NewDaemon(c)
  63. }
  64. func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
  65. testRequires(c, DaemonIsLinux)
  66. s.d.Stop()
  67. s.ds.TearDownTest(c)
  68. }
  69. func init() {
  70. check.Suite(&DockerTrustSuite{
  71. ds: &DockerSuite{},
  72. })
  73. }
  74. type DockerTrustSuite struct {
  75. ds *DockerSuite
  76. reg *testRegistryV2
  77. not *testNotary
  78. }
  79. func (s *DockerTrustSuite) SetUpTest(c *check.C) {
  80. s.reg = setupRegistry(c)
  81. s.not = setupNotary(c)
  82. }
  83. func (s *DockerTrustSuite) TearDownTest(c *check.C) {
  84. s.reg.Close()
  85. s.not.Close()
  86. s.ds.TearDownTest(c)
  87. }