check_test.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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)
  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(&DockerDaemonSuite{
  54. ds: &DockerSuite{},
  55. })
  56. }
  57. type DockerDaemonSuite struct {
  58. ds *DockerSuite
  59. d *Daemon
  60. }
  61. func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
  62. testRequires(c, DaemonIsLinux)
  63. s.d = NewDaemon(c)
  64. }
  65. func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
  66. testRequires(c, DaemonIsLinux)
  67. s.d.Stop()
  68. s.ds.TearDownTest(c)
  69. }
  70. func init() {
  71. check.Suite(&DockerTrustSuite{
  72. ds: &DockerSuite{},
  73. })
  74. }
  75. type DockerTrustSuite struct {
  76. ds *DockerSuite
  77. reg *testRegistryV2
  78. not *testNotary
  79. }
  80. func (s *DockerTrustSuite) SetUpTest(c *check.C) {
  81. s.reg = setupRegistry(c)
  82. s.not = setupNotary(c)
  83. }
  84. func (s *DockerTrustSuite) TearDownTest(c *check.C) {
  85. s.reg.Close()
  86. s.not.Close()
  87. s.ds.TearDownTest(c)
  88. }