当前位置: 首页>>代码示例>>Golang>>正文


Golang Config.SetS3BlobStore方法代码示例

本文整理汇总了Golang中github.com/cloudfoundry-incubator/ltc/config.Config.SetS3BlobStore方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.SetS3BlobStore方法的具体用法?Golang Config.SetS3BlobStore怎么用?Golang Config.SetS3BlobStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cloudfoundry-incubator/ltc/config.Config的用法示例。


在下文中一共展示了Config.SetS3BlobStore方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1:

	"github.com/cloudfoundry-incubator/ltc/blob_store/s3_blob_store"
	config_package "github.com/cloudfoundry-incubator/ltc/config"
)

var _ = Describe("S3BlobStore", func() {
	var (
		verifier   *s3_blob_store.Verifier
		fakeServer *ghttp.Server
		config     *config_package.Config
	)

	BeforeEach(func() {
		fakeServer = ghttp.NewServer()
		verifier = &s3_blob_store.Verifier{fakeServer.URL()}
		config = config_package.New(nil)
		config.SetS3BlobStore("some-access-key", "some-secret-key", "bucket", "some-region")
	})

	Describe("Verify", func() {
		Context("when the blob store credentials are valid", func() {
			It("returns authorized as true", func() {
				responseBody := `
					 <?xml version="1.0" encoding="UTF-8"?>
					 <ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
						 <Name>bucket</Name>
						 <Prefix/>
						 <Marker/>
						 <MaxKeys>1000</MaxKeys>
						 <IsTruncated>false</IsTruncated>
					 </ListBucketResult>
				 `
开发者ID:cloudfoundry-incubator,项目名称:ltc,代码行数:31,代码来源:blob_store_verifier_test.go

示例2:

				Context("when no blob store username is set", func() {
					BeforeEach(func() {
						config.SetBlobStore("blobtarget.com", "8444", "", "")
						Expect(config.Save()).To(Succeed())
					})

					It("only prints the blob store host", func() {
						Expect(outputBuffer).To(test_helpers.SayLine("Droplet store:\tblobtarget.com:8444"))
					})
				})
			})

			Context("when a S3 blob store is targeted", func() {
				BeforeEach(func() {
					config.SetS3BlobStore("access", "secret", "bucket", "region")
					Expect(config.Save()).To(Succeed())
				})

				It("outputs the s3 bucket and region", func() {
					Expect(outputBuffer).To(test_helpers.SayLine("Droplet store:\ts3://bucket (region)"))
				})
			})
		})

		Context("when --domain is pased", func() {
			JustBeforeEach(func() {
				test_helpers.ExecuteCommandWithArgs(targetCommand, []string{"--domain"})
			})

			It("outputs just the target host", func() {
开发者ID:davidwadden,项目名称:ltc,代码行数:30,代码来源:config_command_factory_test.go

示例3:

			var config *config_package.Config

			BeforeEach(func() {
				config = config_package.New(nil)
				config.SetBlobStore("some-host", "some-port", "some-user", "some-password")
			})

			It("returns a new DavBlobStore Verifier", func() {
				verifier.Verify(config)
				Expect(fakeDAVVerifier.VerifyCallCount()).To(Equal(1))
				Expect(fakeS3Verifier.VerifyCallCount()).To(Equal(0))
			})
		})

		Context("when an s3 blob store is targeted", func() {
			var config *config_package.Config

			BeforeEach(func() {
				config = config_package.New(nil)
				config.SetS3BlobStore("", "", "some-bucket-name", "")
			})

			It("returns a new S3BlobStore Verifier", func() {
				verifier.Verify(config)
				Expect(fakeS3Verifier.VerifyCallCount()).To(Equal(1))
				Expect(fakeDAVVerifier.VerifyCallCount()).To(Equal(0))
			})
		})
	})
})
开发者ID:cloudfoundry-incubator,项目名称:ltc,代码行数:30,代码来源:blob_store_test.go

示例4:

		It("returns errors from loading the config", func() {
			testPersister.err = errors.New("Error")

			err := testConfig.Load()
			Expect(err).To(MatchError("Error"))
		})
	})

	Describe("ActiveBlobStore", func() {
		It("defaults to 'dav'", func() {
			Expect(testConfig.ActiveBlobStore().String()).To(Equal("dav"))
		})

		It("reports the active blobstore", func() {
			testConfig.SetS3BlobStore("some-access-key", "some-secret-key", "some-bucket-name", "some-s3-region")
			Expect(testConfig.ActiveBlobStore().String()).To(Equal("s3"))
		})
	})

	Describe("TargetBlob", func() {
		It("sets the blob target", func() {
			testConfig.SetBlobStore("some-host", "7474", "some-username", "some-password")

			Expect(testConfig.BlobStore()).To(Equal(config.BlobStoreConfig{
				Host:     "some-host",
				Port:     "7474",
				Username: "some-username",
				Password: "some-password",
			}))
		})
开发者ID:cloudfoundry-incubator,项目名称:ltc,代码行数:30,代码来源:config_test.go


注:本文中的github.com/cloudfoundry-incubator/ltc/config.Config.SetS3BlobStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。