check_test.go 1.4 KB

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