Exemple #1
0
func (s *LocalServer) SetUp(c *C) {
	srv, err := s3test.NewServer(s.config)
	c.Assert(err, IsNil)
	c.Assert(srv, NotNil)

	s.srv = srv
	s.region = aws.Region{
		Name:                 "faux-region-1",
		S3Endpoint:           srv.URL(),
		S3LocationConstraint: true, // s3test server requires a LocationConstraint
		Sign:                 aws.SignV2,
	}
}
func createS3Bucket(t *testing.T) (*s3test.Server, *s3.Bucket) {
	s3Server, err := s3test.NewServer(&s3test.Config{Send409Conflict: true})
	if err != nil {
		t.Fatalf("Error bringing up fake s3 server: %s\n", err)
	}

	t.Logf("Fake S3 server up at %s\n", s3Server.URL())

	s3Client := s3.New(aws.Auth{AccessKey: "abc", SecretKey: "123"}, aws.Region{
		Name:                 "fake-artifacts-test-region",
		S3Endpoint:           s3Server.URL(),
		S3LocationConstraint: true,
		Sign:                 aws.SignV2,
	})

	s3Bucket := s3Client.Bucket("fake-artifacts-store-bucket")
	if err := s3Bucket.PutBucket(s3.Private); err != nil {
		t.Fatalf("Error creating s3 bucket: %s\n", err)
	}

	return s3Server, s3Bucket
}