From 2ed1f7923fcecb2c4d7f5b201da3f49129ce5f70 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 2 May 2012 02:27:58 +0200 Subject: [PATCH] Added unit tests. --- test/fixtures/test1.pdf | Bin 0 -> 4722 bytes test/unit/store_test.rb | 58 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 test/fixtures/test1.pdf create mode 100644 test/unit/store_test.rb diff --git a/test/fixtures/test1.pdf b/test/fixtures/test1.pdf new file mode 100644 index 0000000000000000000000000000000000000000..6502314a504ab3c13e29538241075ac883d9d67f GIT binary patch literal 4722 zcmbVQ4OA0X7ET~23B=_m_|wy_qZNo?OOi+e>NRxP*%i>9=Kw%fI>Qc!aCpwigtsmtCwGeD(#&USZTGMV@8 zd+*-we)qn26Rb^0d`9}LTqp=`-`9S+{Y3j7p+H7R2vcr>P!JnSM5Izh2FrSagtknf zfFOv7L}Q_aGQ+b_Z=n*XJX1a;6f9mW6qH!ZlzxLyuxa-O?WcmR&-tGA`B(dHpVdG5 zXV2L8dgdR0@6|Z_vl*hoo~5sx?OEM=>`0+^O;>(ERq2z~?blKo*VYcadvebG?A^*u z4~OnNeEG?L{w3=3M7}DdRkHrsq%g0&Jzs0J$JHZir|>@!zOW$k-gficdg7^-+nRWt zyrjeXU$@+D+`RKh?*htmhu8cQ%L2nkv|VYgpb_O$_vQ2M%^vY-s)>F7l@lv=r@g7q zeRJBbx7$D7yrli)lcP5pE}q;NKI=$CeR0uE@1(b$`R>lgjvu*k)0RI$73Gha1z%}Y zgaQPE{z?!s31BzTBOmKQ=yYYp6cMp9J-2|$voP3YS#vFPYw`xY0boNsvyJ%xuuLLh zUXv)JVZCMIU1hYCXeqPWw4vBkL={CYYQ;LHX+y}0znVK1%+=s0DnH(%fb0>}M0 z9$ZgP51uD#4bp#reh$yyD`1W^eoA15e(KzfBH3&2G87&st(AY= z_WB!Dw(6Q4wLAa(Zrv{X-hJ=yZ*m-HK63Qf@e_aj@Z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PN<(aAz z>tTAKAv&p+yMT*nz(SgfWi);bDUIY!1uVY~2PdyFLf%2dkkS zoVW;>(Q`2|2Wf-OQ;__?>p}a=_mX$$tN@rLqkp>4tH2n{FvGgg@&-tZKm+WhlX4U0 z84N}UK`rXo4>Y4w2E;xj6qbJ#r-#oo{6nCjf7O~5pJs^x;adcgl5Lzv!I<6q4+ee& zU>xeSzfEn2@WCJq-8=w9`vUhc2plly%-A0Gi`{_T!a&33z(vdkhFb@l51API#r9Pe zPS0FT=L&Xv>%)|c;jrKk>?E=iz~Ek030U`m-4@m*5ZhnHJ5JLCK?I4Y4p8em8)91o ziR~waijCOnQ#U}B>yVjXH9%d5yVx0squ6^^%rHZ?d6;TGBC{@q<}}9EqWdA~EJ|l{ z2W}P+r5HRDdnD{M%-#_+$S~CjM5bdc*|)VOExXn=wo`V2}R*_l^DHjrfExgTp8`BKmo97*Y zHb?3Y8LKnq0jia)H7NYtMX|kQyM5wh;yL;yeYF4e`Cs|#Q+}eUXz~#skN7 zUqYb-5s^d{zC>A!dHQEmrow!tS5pKvl(EQwr9e@9QHgP^fjOm5R2PvG>#_%ZDS^5` zVTSeBgkaQ!AQ6$gK~7*@!jx~13r0@}vNNKVxDH$FvDFKKGqO!uvnel&vJlS`5l}rs znL}*?!{~xW%|4Uar;1oTSvBdzienX$cDxkQ>djc;C?*!mq)JRya~@SfpsK6}%cy*# zUS-+@DoEf@DU}hC(K1{M!CqoES&IoQz_MTkv%aXL7^lrEBO=t$GF~fzj)cW*r3i!s z2dcq#SiXe70vMKh94b_5yeei&J5;=c8T(uGR75L?DEYXaOO5#@U;zTc*abS!7i)*w zWCbkPQfKAR(kO z_#D3oB@QC6hrUQ 'hello world', + :filename => 'test.txt', + }, + { + :data => 'hello world äöüß', + :filename => 'testäöüß.txt', + }, + { + :data => IO.read('test/fixtures/test1.pdf'), + :filename => 'test.pdf', + }, + ] + + + files.each { |file| + + md5 = Digest::MD5.hexdigest( file[:data] ) + + # add attachments + store = Store.add( + :object => 'Test', + :o_id => 1, + :data => file[:data], + :filename => file[:filename], + :preferences => {} + ) + assert store + + # get list of attachments + attachments = Store.list( + :object => 'Test', + :o_id => 1 + ) + assert attachments + + # md5 check + md5_new = Digest::MD5.hexdigest( attachments[0].store_file.data ) + assert_equal( md5, md5_new ) + + # filename check + assert_equal( file[:filename], attachments[0].filename ) + + # delete attachments + success = Store.remove( + :object => 'Test', + :o_id => 1 + ) + assert success + } + end +end +