Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Run tests using greenmail server
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphtheninja committed Aug 27, 2018
1 parent 8024e8b commit 3c8aec7
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Expand Up @@ -2,6 +2,9 @@ sudo: required

language: node_js

services:
- docker

addons:
apt:
sources:
Expand All @@ -14,14 +17,17 @@ addons:
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CC=gcc-7; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CXX=g++-7; fi
- ./scripts/travis-before-install.sh
- npm run travis-before-install

node_js:
- 10

install:
- npm install

before_script:
- npm run start-test-server

script:
- npm test

Expand Down
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -6,6 +6,9 @@
"rebuild": "node-gyp rebuild --debug --verbose",
"submodule": "git submodule update --recursive --init",
"install": "./scripts/rebuild-all",
"travis-before-install": "./scripts/travis-before-install",
"start-test-server": "./scripts/start-test-server",
"stop-test-server": "./scripts/stop-test-server",
"generate-constants": "./scripts/generate-constants.js",
"test": "standard && npm run dependency-check && nyc node test/index.js",
"coverage": "nyc report --reporter=text-lcov | coveralls",
Expand Down
11 changes: 11 additions & 0 deletions scripts/start-test-server
@@ -0,0 +1,11 @@
#!/bin/bash

# Interactive
#docker run -t -i \
# -e GREENMAIL_OPTS='-Dgreenmail.setup.test.smtps -Dgreenmail.setup.test.imaps -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.users=delta1:delta1,delta2:delta2 -Dgreenmail.verbose' \
# -p 3025:3025 -p 3110:3110 -p 3143:3143 -p 3465:3465 -p 3993:3993 -p 3995:3995 greenmail/standalone:1.5.8

# Daemon
docker run -d --name greenmail \
-e GREENMAIL_OPTS='-Dgreenmail.setup.test.smtp -Dgreenmail.setup.test.imap -Dgreenmail.hostname=0.0.0.0 -Dgreenmail.users=delta1:delta1,delta2:delta2 -Dgreenmail.verbose' \
-p 3025:3025 -p 3110:3110 -p 3143:3143 -p 3465:3465 -p 3993:3993 -p 3995:3995 greenmail/standalone:1.5.8
3 changes: 3 additions & 0 deletions scripts/stop-test-server
@@ -0,0 +1,3 @@
#!/bin/bash

docker rm -f greenmail
File renamed without changes.
21 changes: 13 additions & 8 deletions test/index.js
Expand Up @@ -6,22 +6,27 @@ const fs = require('fs')
const c = require('../constants')
const events = require('../events')

const env = process.env

if (!env.DC_ADDR || !env.DC_MAIL_PW) {
throw new Error('No credentials. Please specify $DC_ADDR and $DC_MAIL_PW !')
}

let dc = null

test('setUp dc context', t => {
t.plan(3)
dc = new DeltaChat({
addr: env.DC_ADDR,
mail_pw: env.DC_MAIL_PW,
addr: 'delta1@delta.localhost',
mail_server: '127.0.0.1',
mail_port: 3143,
mail_user: 'delta1',
mail_pw: 'delta1',
send_server: '127.0.0.1',
send_port: 3025,
send_user: 'delta1',
send_pw: 'delta1',
server_flags: 0x400 | 0x40000,
cwd: tempy.directory()
})
dc.once('ready', () => t.pass('ready event fired'))
dc.on('DC_EVENT_ERROR', (data1, data2) => {
throw new Error(data1 || data2)
})
dc.once('ALL', () => t.pass('ALL event fired at least once'))
dc.open(err => t.error(err, 'no error during open'))
})
Expand Down

0 comments on commit 3c8aec7

Please sign in to comment.