check_test.go 931 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. }