func NewS3Upload(
	bucketName, targetPath, endpoint, key, secret string,
	logger lager.Logger,
	injectors ...S3UploadInjector,
) Task {
	upload := &s3upload{
		bucketName: bucketName,
		targetPath: targetPath,
		endpoint:   endpoint,
		key:        key,
		secret:     secret,
		client:     s3.NewClient(endpoint, key, secret, logger),
		logger:     logger,
	}

	for _, injector := range injectors {
		injector(upload)
	}

	return upload
}
func newApiClient(awsAccessKey, awsSecretAccessKey string) *goamz.S3 {
	logger := lager.NewLogger("logger")
	logger.RegisterSink(lager.NewWriterSink(os.Stdout, lager.DEBUG))
	return s3.NewClient("https://s3.amazonaws.com", awsAccessKey, awsSecretAccessKey, logger).ApiClient()
}
		}
		goamzBucketClient = goamz.New(aws.Auth{}, fakeRegion).Bucket(bucketName)
	})

	Describe("GetOrCreateBucket", func() {
		Context("when the bucket already exists", func() {
			var (
				err    error
				bucket s3.Bucket
			)

			BeforeEach(func() {
				err := goamzBucketClient.PutBucket(goamz.BucketOwnerFull)
				Expect(err).NotTo(HaveOccurred())

				client := s3.NewClient(fakeS3EndpointURL, "accessKey", "secretKey", logger)
				bucket, err = client.GetOrCreateBucket(bucketName)
			})

			AfterEach(func() {
				err := goamzBucketClient.DelBucket()
				Expect(err).NotTo(HaveOccurred())
			})

			It("returns the bucket", func() {
				Expect(bucket.Name()).To(Equal(bucketName))
			})

			It("does not return an error", func() {
				Expect(err).NotTo(HaveOccurred())
			})