@@ -806,6 +806,47 @@ describe('migration', function () {
806806 } ) ;
807807 } ) ;
808808
809+ it ( '#2818 Testing attachments with compaction of dups (local docs)' , function ( ) {
810+ var docs = [
811+ {
812+ _id : '_local/doc1' ,
813+ _attachments : {
814+ 'att.txt' : {
815+ data : 'Zm9vYmFy' , // 'foobar'
816+ content_type : 'text/plain'
817+ }
818+ }
819+ } ,
820+ {
821+ _id : '_local/doc2' ,
822+ _attachments : {
823+ 'att.txt' : {
824+ data : 'Zm9vYmFy' , // 'foobar'
825+ content_type : 'text/plain'
826+ }
827+ }
828+ }
829+ ] ;
830+
831+ var oldPouch = new dbs . first . pouch (
832+ dbs . first . local , dbs . first . localOpts ) ;
833+ return oldPouch . bulkDocs ( docs ) . then ( function ( ) {
834+ return oldPouch . close ( ) ;
835+ } ) . then ( function ( ) {
836+ var newPouch = new dbs . second . pouch ( dbs . second . local ,
837+ { auto_compaction : false } ) ;
838+ return newPouch . get ( '_local/doc1' ) . then ( function ( doc1 ) {
839+ return newPouch . remove ( doc1 ) ;
840+ } ) . then ( function ( ) {
841+ return newPouch . compact ( ) ;
842+ } ) . then ( function ( ) {
843+ return newPouch . get ( '_local/doc2' , { attachments : true } ) ;
844+ } ) . then ( function ( doc2 ) {
845+ doc2 . _attachments [ 'att.txt' ] . data . should . equal ( 'Zm9vYmFy' ) ;
846+ } ) ;
847+ } ) ;
848+ } ) ;
849+
809850 it ( '#2890 PNG content after migration' , function ( ) {
810851 var oldPouch = new dbs . first . pouch (
811852 dbs . first . local , dbs . first . localOpts ) ;
0 commit comments