github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/cf/api/copyapplicationsource/copy_application_source_test.go (about) 1 package copyapplicationsource_test 2 3 import ( 4 "net/http" 5 "net/http/httptest" 6 "time" 7 8 "code.cloudfoundry.org/cli/cf/api/apifakes" 9 . "code.cloudfoundry.org/cli/cf/api/copyapplicationsource" 10 "code.cloudfoundry.org/cli/cf/configuration/coreconfig" 11 "code.cloudfoundry.org/cli/cf/net" 12 "code.cloudfoundry.org/cli/cf/terminal/terminalfakes" 13 testconfig "code.cloudfoundry.org/cli/cf/util/testhelpers/configuration" 14 testnet "code.cloudfoundry.org/cli/cf/util/testhelpers/net" 15 16 "code.cloudfoundry.org/cli/cf/trace/tracefakes" 17 . "github.com/onsi/ginkgo" 18 . "github.com/onsi/gomega" 19 ) 20 21 var _ = Describe("CopyApplicationSource", func() { 22 var ( 23 repo Repository 24 testServer *httptest.Server 25 configRepo coreconfig.ReadWriter 26 ) 27 28 setupTestServer := func(reqs ...testnet.TestRequest) { 29 testServer, _ = testnet.NewServer(reqs) 30 configRepo.SetAPIEndpoint(testServer.URL) 31 } 32 33 BeforeEach(func() { 34 configRepo = testconfig.NewRepositoryWithDefaults() 35 gateway := net.NewCloudControllerGateway(configRepo, time.Now, new(terminalfakes.FakeUI), new(tracefakes.FakePrinter), "") 36 repo = NewCloudControllerCopyApplicationSourceRepository(configRepo, gateway) 37 }) 38 39 AfterEach(func() { 40 testServer.Close() 41 }) 42 43 Describe(".CopyApplication", func() { 44 BeforeEach(func() { 45 setupTestServer(apifakes.NewCloudControllerTestRequest(testnet.TestRequest{ 46 Method: "POST", 47 Path: "/v2/apps/target-app-guid/copy_bits", 48 Matcher: testnet.RequestBodyMatcher(`{ 49 "source_app_guid": "source-app-guid" 50 }`), 51 Response: testnet.TestResponse{ 52 Status: http.StatusCreated, 53 }, 54 })) 55 }) 56 57 It("should return a CopyApplicationModel", func() { 58 err := repo.CopyApplication("source-app-guid", "target-app-guid") 59 Expect(err).ToNot(HaveOccurred()) 60 }) 61 }) 62 })