github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/api/cloudcontroller/ccv3/ccv3_suite_test.go (about) 1 package ccv3_test 2 3 import ( 4 "bytes" 5 "log" 6 "testing" 7 8 . "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3" 9 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/ccv3fakes" 10 . "github.com/onsi/ginkgo" 11 . "github.com/onsi/gomega" 12 . "github.com/onsi/gomega/ghttp" 13 ) 14 15 func TestCcv3(t *testing.T) { 16 RegisterFailHandler(Fail) 17 RunSpecs(t, "Cloud Controller V3 Suite") 18 } 19 20 var server *Server 21 22 var _ = BeforeEach(func() { 23 server = NewTLSServer() 24 25 // Suppresses ginkgo server logs 26 server.HTTPTestServer.Config.ErrorLog = log.New(&bytes.Buffer{}, "", 0) 27 }) 28 29 var _ = AfterEach(func() { 30 server.Close() 31 }) 32 33 func NewFakeRequesterTestClient(requester Requester) (*Client, *ccv3fakes.FakeClock) { 34 var client *Client 35 fakeClock := new(ccv3fakes.FakeClock) 36 37 client = TestClient( 38 Config{AppName: "CF CLI API V3 Test", AppVersion: "Unknown"}, 39 fakeClock, 40 requester, 41 ) 42 43 return client, fakeClock 44 } 45 46 func NewTestClient(config ...Config) (*Client, *ccv3fakes.FakeClock) { 47 var client *Client 48 fakeClock := new(ccv3fakes.FakeClock) 49 50 if config != nil { 51 client = TestClient(config[0], fakeClock, NewRequester(config[0])) 52 } else { 53 singleConfig := Config{AppName: "CF CLI API V3 Test", AppVersion: "Unknown"} 54 client = TestClient( 55 singleConfig, 56 fakeClock, 57 NewRequester(singleConfig), 58 ) 59 } 60 client.TargetCF(TargetSettings{ 61 SkipSSLValidation: true, 62 URL: server.URL(), 63 }) 64 65 return client, fakeClock 66 }