fixed tests

This commit is contained in:
Andris Reinman 2018-12-27 17:44:38 +02:00
parent 6170544751
commit a6cba61f4f
2 changed files with 20 additions and 25 deletions

View file

@ -2,10 +2,10 @@
DBNAME="$1"
#echo "Clearing DB"
echo "Clearing DB"
mongo "$DBNAME" --eval "db.getCollectionNames().forEach(function(key){db[key].deleteMany({});})" > /dev/null
#echo "Creating user"
echo "Creating user"
USERRESPONSE=`curl --silent -XPOST http://localhost:8080/users \
-H 'Content-type: application/json' \
-d '{
@ -13,13 +13,13 @@ USERRESPONSE=`curl --silent -XPOST http://localhost:8080/users \
"password": "pass",
"name": "Test User"
}'`
#echo "UR: $USERRESPONSE"
echo "UR: $USERRESPONSE"
USERID=`echo "$USERRESPONSE" | jq -r '.id'`
#echo "Reading Mailbox ID"
echo "Reading Mailbox ID"
MAILBOXLIST=`curl --silent "http://localhost:8080/users/$USERID/mailboxes"`
#echo "ML: $MAILBOXLIST"
#echo "$MAILBOXLIST" | jq
echo "ML: $MAILBOXLIST"
echo "$MAILBOXLIST" | jq
INBOXID=`echo "$MAILBOXLIST" | jq -r '.results[0].id'`
SENTID=`echo "$MAILBOXLIST" | jq -r '.results[3].id'`
@ -27,26 +27,26 @@ curl --silent -XPUT "http://localhost:8080/users/$USERID/mailboxes/$SENTID" \
-H 'Content-type: application/json' \
-d '{
"path": "[Gmail]/Sent Mail"
}' > /dev/null
}'
MAILBOXLIST=`curl --silent "http://localhost:8080/users/$USERID/mailboxes"`
#echo "$MAILBOXLIST" | jq
echo "$MAILBOXLIST" | jq
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?date=14-Sep-2013%2021%3A22%3A28%20-0300&unseen=true" \
-H 'Content-type: message/rfc822' \
--data-binary "@fixtures/fix1.eml" > /dev/null
--data-binary "@fixtures/fix1.eml"
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=false" \
-H 'Content-type: message/rfc822' \
--data-binary "@fixtures/fix2.eml" > /dev/null
--data-binary "@fixtures/fix2.eml"
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=false" \
-H 'Content-type: message/rfc822' \
--data-binary "@fixtures/fix3.eml" > /dev/null
--data-binary "@fixtures/fix3.eml"
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=true" \
-H 'Content-type: message/rfc822' \
--data-binary "@fixtures/fix4.eml" > /dev/null
--data-binary "@fixtures/fix4.eml"
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=true" \
-H 'Content-type: message/rfc822' \
@ -55,7 +55,7 @@ to: receiver@example.com
subject: test5
hello 5
" > /dev/null
"
curl --silent -XPOST "http://localhost:8080/users/$USERID/mailboxes/$INBOXID/messages?unseen=true" \
-H 'Content-type: message/rfc822' \
@ -64,7 +64,7 @@ to: receiver@example.com
subject: test6
hello 6
" > /dev/null
"
mongo "$DBNAME" --eval "db.mailboxes.updateOne({_id: ObjectId('$INBOXID')}, {\$set:{modifyIndex: 5000, uidNext: 1000}});
db.messages.updateOne({mailbox: ObjectId('$INBOXID'), uid:1}, {\$set:{modseq: 100}});

View file

@ -18,9 +18,9 @@ describe('IMAP Protocol integration tests', function() {
let port = 9993;
beforeEach(function(done) {
exec(__dirname + '/prepare.sh ' + config.dbs.dbname, { cwd: __dirname }, (err, stdout, stderr) => {
console.log(stdout.toString());
console.log(stderr.toString());
exec(__dirname + '/prepare.sh ' + config.dbs.dbname, { cwd: __dirname }, (err /*, stdout, stderr*/) => {
// console.log(stdout.toString());
// console.log(stderr.toString());
if (err) {
return done(err);
}
@ -606,8 +606,7 @@ describe('IMAP Protocol integration tests', function() {
);
});
it.only('should append large file in chunks', function(done) {
console.log(0);
it('should append large file in chunks', function(done) {
let lchunks = [].concat(chunks);
let message = lchunks.join('');
@ -618,19 +617,15 @@ describe('IMAP Protocol integration tests', function() {
'T3 LOGOUT'
];
console.log(0, cmds.length);
console.log(1);
testClient(
{
commands: cmds,
secure: true,
debug: true,
port //debug: true
//debug: true,
port
},
function(resp) {
console.log(2);
resp = resp.toString();
console.log(resp);
expect(/^T2 OK/m.test(resp)).to.be.true;
expect(resp.indexOf('\r\n* LIST (\\HasNoChildren) "/" "testfolder"\r\n') >= 0).to.be.false;
expect(/^[^\s]+ BAD/m.test(resp)).to.be.false;