check_test.go 1.6 KB

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