Skip to content

Commit a145ba3

Browse files
committed
chore: upgrade tests
1 parent 1a7b404 commit a145ba3

File tree

9 files changed

+274
-484
lines changed

9 files changed

+274
-484
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
node_modules
1+
node_modules/
22
/index.js
33
/cli.js
44
/es6.js
55
/couch-store.js
66
/memory-store.js
7-
config.json
87
/test.js
8+
config.json
99
log.txt
10-
tmp_test_data

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
Makefile
33
rollup.config.js
44
log.txt
5-
tmp_test_data
5+
config.json

Makefile

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,13 @@ couch-store.js: src/couch-store.js $(SRC)
2020
memory-store.js: src/memory-store.js $(SRC)
2121
$(BIN)/rollup $< -c -f cjs > $@
2222

23-
test.js: test/run.js index.js couch-store.js memory-store.js $(TEST)
23+
test.js: test/index.js index.js couch-store.js memory-store.js $(TEST)
2424
$(BIN)/rollup $< -c -f cjs > $@
2525

26-
test: test.js install-self
26+
test: test.js
2727
node $<
28-
make clean-self
2928

30-
install-self: clean-self
31-
ln -s ../ node_modules/couchdb-jwt
32-
33-
clean-self:
34-
rm -f node_modules/couchdb-jwt
35-
36-
clean: clean-self
29+
clean:
3730
rm -f index.js es6.js cli.js couch-store.js memory-store.js test.js
3831

39-
.PHONY: build clean test install-self clean-self
32+
.PHONY: build clean test

bin/test.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
BIN=node_modules/.bin
4+
export COUCHDB_URL=http://localhost:16392
5+
export COUCHDB_SECRET=secret
6+
export COUCHDB_USER=testuser
7+
export COUCHDB_PASS=test
8+
9+
# setup the data directory
10+
echo "{ \"jwt_auth\": { \"hs_secret\": \"$(echo -n $COUCHDB_SECRET | openssl base64)\" } }" > config.json
11+
12+
# start db server in background using cli file
13+
$BIN/express-jwt-pouchdb -m -p 16392 &
14+
SERVER_PID=$!
15+
sleep 5
16+
17+
# add a user
18+
curl -X PUT "$COUCHDB_URL/_users/org.couchdb.user:$COUCHDB_USER" \
19+
-H "Content-Type: application/json" \
20+
-d "{\"password\":\"$COUCHDB_PASS\",\"type\":\"user\",\"name\":\"$COUCHDB_USER\",\"roles\":[]}"
21+
22+
# run tests
23+
make test
24+
TEST_CODE=$?
25+
26+
# clean up and exit
27+
kill $SERVER_PID
28+
rm -rf ./tmp_test_data
29+
exit $TEST_CODE

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"scripts": {
1919
"lint": "eslint src/ test/",
2020
"build": "make clean && make",
21-
"test": "make test",
21+
"test": "bin/test.sh",
2222
"prepublish": "npm run build",
2323
"autorelease": "autorelease pre && npm publish && autorelease post"
2424
},
@@ -36,29 +36,29 @@
3636
"autorelease-github": "^1.1.1",
3737
"autorelease-travis": "^1.2.0",
3838
"babel": "^6.5.2",
39-
"babel-cli": "^6.5.1",
4039
"babel-eslint": "~5.0.0",
4140
"babel-plugin-external-helpers": "^6.5.0",
4241
"babel-plugin-transform-async-to-generator": "^6.5.0",
4342
"babel-plugin-transform-es2015-destructuring": "^6.5.0",
4443
"babel-plugin-transform-es2015-parameters": "^6.5.0",
4544
"babel-plugin-transform-export-extensions": "^6.5.0",
4645
"babel-plugin-transform-object-rest-spread": "^6.5.0",
47-
"del": "^2.2.0",
4846
"eslint": "~2.2.0",
49-
"express-pouchdb": "^1.0.3",
50-
"fs-promise": "^0.5.0",
47+
"express-jwt-pouchdb": "^1.1.0",
5148
"rollup": "~0.25.3",
5249
"rollup-plugin-babel": "~2.3.9",
53-
"superagent-prefix": "0.0.2",
54-
"superagent-promise-plugin": "^2.1.0",
50+
"supertest": "^1.2.0",
5551
"tape": "~4.4.0"
5652
},
5753
"keywords": [
5854
"couchdb",
5955
"jsonwebtoken",
6056
"jwt",
61-
"authentication"
57+
"authentication",
58+
"pouchdb",
59+
"auth",
60+
"token",
61+
"session"
6262
],
6363
"license": "MIT"
6464
}

test/express-jwt.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

test/express-pouchdb.js

Lines changed: 0 additions & 125 deletions
This file was deleted.

0 commit comments

Comments
 (0)