github.com/uriddle/docker@v0.0.0-20210926094723-4072e6aeb013/integration-cli/check_test.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  
     7  	"github.com/docker/docker/pkg/reexec"
     8  	"github.com/go-check/check"
     9  )
    10  
    11  func Test(t *testing.T) {
    12  	reexec.Init() // This is required for external graphdriver tests
    13  
    14  	if !isLocalDaemon {
    15  		fmt.Println("INFO: Testing against a remote daemon")
    16  	} else {
    17  		fmt.Println("INFO: Testing against a local daemon")
    18  	}
    19  
    20  	check.TestingT(t)
    21  }
    22  
    23  func init() {
    24  	check.Suite(&DockerSuite{})
    25  }
    26  
    27  type DockerSuite struct {
    28  }
    29  
    30  func (s *DockerSuite) TearDownTest(c *check.C) {
    31  	unpauseAllContainers()
    32  	deleteAllContainers()
    33  	deleteAllImages()
    34  	deleteAllVolumes()
    35  	deleteAllNetworks()
    36  }
    37  
    38  func init() {
    39  	check.Suite(&DockerRegistrySuite{
    40  		ds: &DockerSuite{},
    41  	})
    42  }
    43  
    44  type DockerRegistrySuite struct {
    45  	ds  *DockerSuite
    46  	reg *testRegistryV2
    47  	d   *Daemon
    48  }
    49  
    50  func (s *DockerRegistrySuite) SetUpTest(c *check.C) {
    51  	testRequires(c, DaemonIsLinux)
    52  	s.reg = setupRegistry(c, false)
    53  	s.d = NewDaemon(c)
    54  }
    55  
    56  func (s *DockerRegistrySuite) TearDownTest(c *check.C) {
    57  	if s.reg != nil {
    58  		s.reg.Close()
    59  	}
    60  	if s.d != nil {
    61  		s.d.Stop()
    62  	}
    63  	s.ds.TearDownTest(c)
    64  }
    65  
    66  func init() {
    67  	check.Suite(&DockerSchema1RegistrySuite{
    68  		ds: &DockerSuite{},
    69  	})
    70  }
    71  
    72  type DockerSchema1RegistrySuite struct {
    73  	ds  *DockerSuite
    74  	reg *testRegistryV2
    75  	d   *Daemon
    76  }
    77  
    78  func (s *DockerSchema1RegistrySuite) SetUpTest(c *check.C) {
    79  	testRequires(c, DaemonIsLinux)
    80  	s.reg = setupRegistry(c, true)
    81  	s.d = NewDaemon(c)
    82  }
    83  
    84  func (s *DockerSchema1RegistrySuite) TearDownTest(c *check.C) {
    85  	if s.reg != nil {
    86  		s.reg.Close()
    87  	}
    88  	if s.d != nil {
    89  		s.d.Stop()
    90  	}
    91  	s.ds.TearDownTest(c)
    92  }
    93  
    94  func init() {
    95  	check.Suite(&DockerDaemonSuite{
    96  		ds: &DockerSuite{},
    97  	})
    98  }
    99  
   100  type DockerDaemonSuite struct {
   101  	ds *DockerSuite
   102  	d  *Daemon
   103  }
   104  
   105  func (s *DockerDaemonSuite) SetUpTest(c *check.C) {
   106  	testRequires(c, DaemonIsLinux)
   107  	s.d = NewDaemon(c)
   108  }
   109  
   110  func (s *DockerDaemonSuite) TearDownTest(c *check.C) {
   111  	testRequires(c, DaemonIsLinux)
   112  	if s.d != nil {
   113  		s.d.Stop()
   114  	}
   115  	s.ds.TearDownTest(c)
   116  }
   117  
   118  func init() {
   119  	check.Suite(&DockerTrustSuite{
   120  		ds: &DockerSuite{},
   121  	})
   122  }
   123  
   124  type DockerTrustSuite struct {
   125  	ds  *DockerSuite
   126  	reg *testRegistryV2
   127  	not *testNotary
   128  }
   129  
   130  func (s *DockerTrustSuite) SetUpTest(c *check.C) {
   131  	s.reg = setupRegistry(c, false)
   132  	s.not = setupNotary(c)
   133  }
   134  
   135  func (s *DockerTrustSuite) TearDownTest(c *check.C) {
   136  	if s.reg != nil {
   137  		s.reg.Close()
   138  	}
   139  	if s.not != nil {
   140  		s.not.Close()
   141  	}
   142  	s.ds.TearDownTest(c)
   143  }