github.com/asifdxtreme/cli@v6.1.3-0.20150123051144-9ead8700b4ae+incompatible/cf/api/copy_application_source/copy_application_source_test.go (about) 1 package copy_application_source_test 2 3 import ( 4 "net/http" 5 "net/http/httptest" 6 "time" 7 8 . "github.com/cloudfoundry/cli/cf/api/copy_application_source" 9 testapi "github.com/cloudfoundry/cli/cf/api/fakes" 10 "github.com/cloudfoundry/cli/cf/configuration/core_config" 11 "github.com/cloudfoundry/cli/cf/net" 12 testconfig "github.com/cloudfoundry/cli/testhelpers/configuration" 13 testnet "github.com/cloudfoundry/cli/testhelpers/net" 14 testterm "github.com/cloudfoundry/cli/testhelpers/terminal" 15 16 . "github.com/onsi/ginkgo" 17 . "github.com/onsi/gomega" 18 ) 19 20 var _ = Describe("CopyApplicationSource", func() { 21 var ( 22 repo CopyApplicationSourceRepository 23 testServer *httptest.Server 24 testHandler *testnet.TestHandler 25 configRepo core_config.ReadWriter 26 ) 27 28 setupTestServer := func(reqs ...testnet.TestRequest) { 29 testServer, testHandler = testnet.NewServer(reqs) 30 configRepo.SetApiEndpoint(testServer.URL) 31 } 32 33 BeforeEach(func() { 34 configRepo = testconfig.NewRepositoryWithDefaults() 35 gateway := net.NewCloudControllerGateway(configRepo, time.Now, &testterm.FakeUI{}) 36 repo = NewCloudControllerCopyApplicationSourceRepository(configRepo, gateway) 37 }) 38 39 AfterEach(func() { 40 testServer.Close() 41 }) 42 43 Describe(".CopyApplication", func() { 44 BeforeEach(func() { 45 setupTestServer(testapi.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 })