From 7f200f886a2a32071b108791d686c4cddeec6062 Mon Sep 17 00:00:00 2001
From: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
Date: Sat, 17 Jan 2015 23:42:10 -0800
Subject: [PATCH] Add TestPutContentMultipleTimes to storage driver suite

Signed-off-by: Ahmet Alp Balkan <ahmetalpbalkan@gmail.com>
---
 storagedriver/testsuites/testsuites.go | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/storagedriver/testsuites/testsuites.go b/storagedriver/testsuites/testsuites.go
index c3229fcc..f1cba8c1 100644
--- a/storagedriver/testsuites/testsuites.go
+++ b/storagedriver/testsuites/testsuites.go
@@ -735,6 +735,27 @@ func (suite *DriverSuite) TestStatCall(c *check.C) {
 	}
 }
 
+// TestPutContentMultipleTimes checks that if storage driver can overwrite the content
+// in the subsequent puts. Validates that PutContent does not have to work
+// with an offset like WriteStream does and overwrites the file entirely
+// rather than writing the data to the [0,len(data)) of the file.
+func (suite *DriverSuite) TestPutContentMultipleTimes(c *check.C) {
+	filename := randomPath(32)
+	contents := randomContents(4096)
+
+	defer suite.StorageDriver.Delete(firstPart(filename))
+	err := suite.StorageDriver.PutContent(filename, contents)
+	c.Assert(err, check.IsNil)
+
+	contents = randomContents(2048) // upload a different, smaller file
+	err = suite.StorageDriver.PutContent(filename, contents)
+	c.Assert(err, check.IsNil)
+
+	readContents, err := suite.StorageDriver.GetContent(filename)
+	c.Assert(err, check.IsNil)
+	c.Assert(readContents, check.DeepEquals, contents)
+}
+
 // TestConcurrentStreamReads checks that multiple clients can safely read from
 // the same file simultaneously with various offsets.
 func (suite *DriverSuite) TestConcurrentStreamReads(c *check.C) {