check_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. s.d = NewDaemon(c)
  50. }
  51. func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
  52. s.d.Stop()
  53. s.ds.TearDownTest(c)
  54. }
  55. func init() {
  56. check.Suite(&DockerTrustSuite{
  57. ds: &DockerSuite{},
  58. })
  59. }
  60. type DockerTrustSuite struct {
  61. ds *DockerSuite
  62. reg *testRegistryV2
  63. not *testNotary
  64. }
  65. func (s *DockerTrustSuite) SetUpTest(c *check.C) {
  66. s.reg = setupRegistry(c)
  67. s.not = setupNotary(c)
  68. }
  69. func (s *DockerTrustSuite) TearDownTest(c *check.C) {
  70. s.reg.Close()
  71. s.not.Close()
  72. s.ds.TearDownTest(c)
  73. }