Exemplo n.º 1
0
	"io/ioutil"
	"net/http"
	"net/http/httptest"
	"os"
	"path/filepath"
	"runtime"
	"sort"
	testconfig "testhelpers/configuration"
	testnet "testhelpers/net"
)

var _ = Describe("BuildpackBitsRepository", func() {
	var (
		buildpacksDir     string
		configRepo        configuration.Repository
		repo              CloudControllerBuildpackBitsRepository
		buildpack         models.Buildpack
		testServer        *httptest.Server
		testServerHandler *testnet.TestHandler
	)

	BeforeEach(func() {
		gateway := net.NewCloudControllerGateway()
		pwd, _ := os.Getwd()

		buildpacksDir = filepath.Join(pwd, "../../fixtures/buildpacks")
		configRepo = testconfig.NewRepositoryWithDefaults()
		repo = NewCloudControllerBuildpackBitsRepository(configRepo, gateway, cf.ApplicationZipper{})
		buildpack = models.Buildpack{Name: "my-cool-buildpack", Guid: "my-cool-buildpack-guid"}

		testServer, testServerHandler = testnet.NewTLSServer([]testnet.TestRequest{uploadBuildpackRequest()})
		configRepo.SetApiEndpoint(testServer.URL)
Exemplo n.º 2
0
				ts, handler := testnet.NewTLSServer([]testnet.TestRequest{
					uploadBuildpackRequest(buildpackPath),
				})
				defer ts.Close()

				configRepo.SetApiEndpoint(ts.URL)

				apiResponse := repo.UploadBuildpack(buildpack, buildpackPath)
				Expect(handler.AllRequestsCalled()).To(BeTrue())
				Expect(apiResponse.IsSuccessful()).To(BeTrue())
			})
		})

		Describe("when given the URL of a buildpack", func() {
			var handler *testnet.TestHandler
			var apiServer *httptest.Server

			BeforeEach(func() {
				apiServer, handler = testnet.NewTLSServer([]testnet.TestRequest{
					uploadBuildpackRequest("example-buildpack.zip"),
				})
				configRepo.SetApiEndpoint(apiServer.URL)
			})

			AfterEach(func() {
				apiServer.Close()
			})

			var buildpackFileServerHandler = func(buildpackName string) http.HandlerFunc {
				return func(writer http.ResponseWriter, request *http.Request) {