check_test.go 1.4 KB

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