Esempio n. 1
0
func testContentMd5Set(c *check.C, create func() Driver) {
	drivers := create()
	err := drivers.CreateBucket("bucket", "")
	c.Assert(err, check.IsNil)

	// test md5 invalid
	badmd5Sum := "NWJiZjVhNTIzMjhlNzQzOWFlNmU3MTlkZmU3MTIyMDA"
	calculatedmd5sum, err := drivers.CreateObject("bucket", "one", "", badmd5Sum, int64(len("one")), bytes.NewBufferString("one"))
	c.Assert(err, check.Not(check.IsNil))
	c.Assert(calculatedmd5sum, check.Not(check.Equals), badmd5Sum)

	goodmd5sum := "NWJiZjVhNTIzMjhlNzQzOWFlNmU3MTlkZmU3MTIyMDA="
	calculatedmd5sum, err = drivers.CreateObject("bucket", "two", "", goodmd5sum, int64(len("one")), bytes.NewBufferString("one"))
	c.Assert(err, check.IsNil)
	c.Assert(calculatedmd5sum, check.Equals, goodmd5sum)
}
Esempio n. 2
0
func testBucketRecreateFails(c *check.C, create func() Driver) {
	drivers := create()
	err := drivers.CreateBucket("string", "")
	c.Assert(err, check.IsNil)
	err = drivers.CreateBucket("string", "")
	c.Assert(err, check.Not(check.IsNil))
}
Esempio n. 3
0
func testListObjectsTestsForNonExistantBucket(c *check.C, create func() Driver) {
	drivers := create()
	resources := BucketResourcesMetadata{Prefix: "", Maxkeys: 1000}
	objects, resources, err := drivers.ListObjects("bucket", resources)
	c.Assert(err, check.Not(check.IsNil))
	c.Assert(resources.IsTruncated, check.Equals, false)
	c.Assert(len(objects), check.Equals, 0)
}
Esempio n. 4
0
func (s *HelpersS) TestMkDir(c *check.C) {
	helper := MkDirHelper{}
	output := String{}
	check.Run(&helper, &check.RunConf{Output: &output})
	c.Assert(output.value, check.Equals, "")
	c.Check(helper.isDir1, check.Equals, true)
	c.Check(helper.isDir2, check.Equals, true)
	c.Check(helper.isDir3, check.Equals, true)
	c.Check(helper.isDir4, check.Equals, true)
	c.Check(helper.path1, check.Not(check.Equals),
		helper.path2)
	c.Check(isDir(helper.path1), check.Equals, false)
	c.Check(isDir(helper.path2), check.Equals, false)
}
Esempio n. 5
0
func testNonExistantObjectInBucket(c *check.C, create func() Driver) {
	drivers := create()
	err := drivers.CreateBucket("bucket", "")
	c.Assert(err, check.IsNil)

	var byteBuffer bytes.Buffer
	length, err := drivers.GetObject(&byteBuffer, "bucket", "dir1")
	c.Assert(length, check.Equals, int64(0))
	c.Assert(err, check.Not(check.IsNil))
	c.Assert(len(byteBuffer.Bytes()), check.Equals, 0)
	switch err := iodine.ToError(err).(type) {
	case ObjectNotFound:
		{
			c.Assert(err, check.ErrorMatches, "Object not Found: bucket#dir1")
		}
	default:
		{
			c.Assert(err, check.Equals, "fails")
		}
	}
}
Esempio n. 6
0
func testObjectOverwriteFails(c *check.C, create func() Driver) {
	drivers := create()
	drivers.CreateBucket("bucket", "")

	hasher1 := md5.New()
	hasher1.Write([]byte("one"))
	md5Sum1 := base64.StdEncoding.EncodeToString(hasher1.Sum(nil))
	md5Sum1hex := hex.EncodeToString(hasher1.Sum(nil))
	md5Sum11, err := drivers.CreateObject("bucket", "object", "", md5Sum1, int64(len("one")), bytes.NewBufferString("one"))
	c.Assert(err, check.IsNil)
	c.Assert(md5Sum1hex, check.Equals, md5Sum11)

	hasher2 := md5.New()
	hasher2.Write([]byte("three"))
	md5Sum2 := base64.StdEncoding.EncodeToString(hasher2.Sum(nil))
	_, err = drivers.CreateObject("bucket", "object", "", md5Sum2, int64(len("three")), bytes.NewBufferString("three"))
	c.Assert(err, check.Not(check.IsNil))

	var bytesBuffer bytes.Buffer
	length, err := drivers.GetObject(&bytesBuffer, "bucket", "object")
	c.Assert(err, check.IsNil)
	c.Assert(length, check.Equals, int64(len("one")))
	c.Assert(string(bytesBuffer.Bytes()), check.Equals, "one")
}
Esempio n. 7
0
func testNonExistantBucketOperations(c *check.C, create func() Driver) {
	drivers := create()
	_, err := drivers.CreateObject("bucket", "object", "", "", int64(len("one")), bytes.NewBufferString("one"))
	c.Assert(err, check.Not(check.IsNil))
}
Esempio n. 8
0
func (s *CheckersS) TestNot(c *check.C) {
	testInfo(c, check.Not(check.IsNil), "Not(IsNil)", []string{"value"})

	testCheck(c, check.Not(check.IsNil), false, "", nil)
	testCheck(c, check.Not(check.IsNil), true, "", "a")
}