check_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package main
  2. import (
  3. "fmt"
  4. "testing"
  5. "time"
  6. "github.com/go-check/check"
  7. )
  8. func Test(t *testing.T) {
  9. check.TestingT(t)
  10. }
  11. type TimerSuite struct {
  12. start time.Time
  13. }
  14. func (s *TimerSuite) SetUpTest(c *check.C) {
  15. s.start = time.Now()
  16. }
  17. func (s *TimerSuite) TearDownTest(c *check.C) {
  18. fmt.Printf("%-60s%.2f\n", c.TestName(), time.Since(s.start).Seconds())
  19. }
  20. func init() {
  21. check.Suite(&DockerSuite{})
  22. }
  23. type DockerSuite struct {
  24. TimerSuite
  25. }
  26. func (s *DockerSuite) TearDownTest(c *check.C) {
  27. deleteAllContainers()
  28. deleteAllImages()
  29. s.TimerSuite.TearDownTest(c)
  30. }
  31. func init() {
  32. check.Suite(&DockerRegistrySuite{
  33. ds: &DockerSuite{},
  34. })
  35. }
  36. type DockerRegistrySuite struct {
  37. ds *DockerSuite
  38. reg *testRegistryV2
  39. }
  40. func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
  41. s.reg = setupRegistry(c)
  42. s.ds.SetUpTest(c)
  43. }
  44. func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
  45. s.reg.Close()
  46. s.ds.TearDownTest(c)
  47. }
  48. func init() {
  49. check.Suite(&DockerDaemonSuite{
  50. ds: &DockerSuite{},
  51. })
  52. }
  53. type DockerDaemonSuite struct {
  54. ds *DockerSuite
  55. d *Daemon
  56. }
  57. func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
  58. s.d = NewDaemon(c)
  59. s.ds.SetUpTest(c)
  60. }
  61. func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
  62. s.d.Stop()
  63. s.ds.TearDownTest(c)
  64. }