func (t *localNonUSEastSuite) TestPutBucket(c *C) { p := ec2.WritablePublicStorage(t.env).(ec2.Storage) for i := 0; i < 5; i++ { p.ResetMadeBucket() var buf bytes.Buffer err := p.Put("test-file", &buf, 0) c.Assert(err, IsNil) } }
func (t *LiveTests) SetUpSuite(c *C) { t.LoggingSuite.SetUpSuite(c) e, err := environs.NewFromAttrs(t.Config) c.Assert(err, IsNil) // Environ.PublicStorage() is read only. // For testing, we create a specific storage instance which is authorised to write to // the public storage bucket so that we can upload files for testing. t.writablePublicStorage = ec2.WritablePublicStorage(e) // Put some fake tools in place so that tests that are simply // starting instances without any need to check if those instances // are running will find them in the public bucket. putFakeTools(c, t.writablePublicStorage) t.LiveTests.SetUpSuite(c) }
func (t *LiveTests) TestPublicStorage(c *C) { s := ec2.WritablePublicStorage(t.Env) contents := "test" err := s.Put("test-object", strings.NewReader(contents), int64(len(contents))) c.Assert(err, IsNil) r, err := s.Get("test-object") c.Assert(err, IsNil) defer r.Close() data, err := ioutil.ReadAll(r) c.Assert(err, IsNil) c.Assert(string(data), Equals, contents) // Check that the public storage isn't aliased to the private storage. r, err = t.Env.Storage().Get("test-object") var notFoundError *errors.NotFoundError c.Assert(err, FitsTypeOf, notFoundError) }