From 45d12baba2449fc1117a1f1d7965a7859d13f17a Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@lothar.com>
Date: Mon, 4 Aug 2008 13:26:43 -0700
Subject: [PATCH] test_cli: more coverage for 'tahoe put' modifying a mutable
 file in-place, by filename, closes #441

---
 src/allmydata/test/test_cli.py | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py
index b1788653..5fdf6f40 100644
--- a/src/allmydata/test/test_cli.py
+++ b/src/allmydata/test/test_cli.py
@@ -442,7 +442,32 @@ class Put(SystemTestMixin, CLITestMixin, unittest.TestCase):
         return d
 
     def test_mutable(self):
-        # tahoe put --mutable file.txt uploaded.txt
-        # tahoe put - uploaded.txt  # should modify-in-place
-        pass # TODO
+        # echo DATA1 | tahoe put --mutable - uploaded.txt
+        # echo DATA2 | tahoe put - uploaded.txt # should modify-in-place
+        # tahoe get uploaded.txt, compare against DATA2
+
+        self.basedir = os.path.dirname(self.mktemp())
+        DATA1 = "data" * 100
+        fn1 = os.path.join(self.basedir, "DATA1")
+        f = open(fn1, "w")
+        f.write(DATA1)
+        f.close()
+        DATA2 = "two" * 100
+        fn2 = os.path.join(self.basedir, "DATA2")
+        f = open(fn2, "w")
+        f.write(DATA2)
+        f.close()
+
+        d = self.set_up_nodes()
+        d.addCallback(lambda res: self.do_cli("create-alias", "tahoe"))
+        d.addCallback(lambda res:
+                      self.do_cli("put", "--mutable", fn1, "tahoe:uploaded.txt"))
+        d.addCallback(lambda res:
+                      self.do_cli("put", fn2, "tahoe:uploaded.txt"))
+        d.addCallback(lambda res:
+                      self.do_cli("get", "tahoe:uploaded.txt"))
+        d.addCallback(lambda (out,err): self.failUnlessEqual(out, DATA2))
+        return d
+
+
 
-- 
2.45.2