Browse files

Start adding attachment tests

  • Loading branch information...
1 parent 09ea423 commit 6cb139c5e338c79b01691a426b27cad970f70918 @daleharvey daleharvey committed Apr 1, 2012
Showing with 44 additions and 3 deletions.
  1. +6 −2 src/pouch.js
  2. +36 −0 tests/test.attachments.js
  3. +1 −0 tests/test.html
  4. +1 −1 tests/test.replication.js
View
8 src/pouch.js
@@ -375,8 +375,12 @@ parseUri.options = {
callback = opts;
opts = {};
}
- var params = '';
- ajax({auth: host.auth, type:'PUT', url: genUrl(host, doc._id + params), data: doc}, callback);
+ ajax({
+ auth: host.auth,
+ type:'PUT',
+ url: genUrl(host, doc._id),
+ data: doc
+ }, callback);
};
db.bulkDocs = function(req, opts, callback) {
if (typeof opts.newEdits !== 'undefined') {
View
36 tests/test.attachments.js
@@ -0,0 +1,36 @@
+var remote = {
+ host: 'localhost:1234'
+};
+
+module('attachments', {
+ setup : function () {
+ this.name = 'test_suite_db';
+ this.remote = 'http://' + remote.host + '/test_suite_db/';
+ this.name = this.remote;
+ }
+});
+
+asyncTest("Test some attachments", function() {
+
+ var binAttDoc = {
+ _id: "bin_doc",
+ _attachments:{
+ "foo.txt": {
+ content_type:"text/plain",
+ data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
+ }
+ }
+ };
+
+ initTestDB(this.name, function(err, db) {
+ db.put(binAttDoc, function(err, _) {
+ ok(!err, 'saved doc with attachment');
+ db.get('bin_doc/foo.txt', function() {
+ console.log(arguments);
+ start();
+ });
+ });
+ });
+
+});
+
View
1 tests/test.html
@@ -12,6 +12,7 @@
<script type="text/javascript" src="test.conflicts.js"></script>
<script type="text/javascript" src="test.merge_rev_tree.js"></script>
<script type="text/javascript" src="test.revs_diff.js"></script>
+ <script type="text/javascript" src="test.attachments.js"></script>
<script type="text/javascript" src="test.replication.js"></script>
<script type="text/javascript" src="../src/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../src/uuid.js" ></script>
View
2 tests/test.replication.js
@@ -107,4 +107,4 @@ asyncTest("Test basic conflict", function() {
});
});
});
-});
+});

0 comments on commit 6cb139c

Please sign in to comment.