예제 #1
0
func (srv *localServer) startServer(c *C) {
	var err error
	srv.ec2srv, err = ec2test.NewServer()
	if err != nil {
		c.Fatalf("cannot start ec2 test server: %v", err)
	}
	srv.s3srv, err = s3test.NewServer(srv.config)
	if err != nil {
		c.Fatalf("cannot start s3 test server: %v", err)
	}
	aws.Regions["test"] = aws.Region{
		Name:                 "test",
		EC2Endpoint:          srv.ec2srv.URL(),
		S3Endpoint:           srv.s3srv.URL(),
		S3LocationConstraint: true,
	}
	s3inst := s3.New(aws.Auth{}, aws.Regions["test"])
	putFakeTools(c, ec2.BucketStorage(s3inst.Bucket("public-tools")))
	srv.addSpice(c)
}
예제 #2
0
func (t *LiveTests) TestPutBucketOnlyOnce(c *C) {
	s3inst := ec2.EnvironS3(t.Env)
	b := s3inst.Bucket("test-once-" + uniqueName)
	s := ec2.BucketStorage(b)

	// Check that we don't do a PutBucket every time by
	// getting it to create the bucket, destroying the bucket behind
	// the scenes, and trying to put another object,
	// which should fail because it doesn't try to do
	// the PutBucket again.

	err := s.Put("test-object", strings.NewReader("test"), 4)
	c.Assert(err, IsNil)

	err = s.Remove("test-object")
	c.Assert(err, IsNil)

	err = b.DelBucket()
	c.Assert(err, IsNil)

	err = s.Put("test-object", strings.NewReader("test"), 4)
	c.Assert(err, ErrorMatches, ".*The specified bucket does not exist")
}