Skip to content

Commit c95729e

Browse files
author
bweigel
committed
start moving caching tests to tape
1 parent 757762f commit c95729e

File tree

3 files changed

+57
-20
lines changed

3 files changed

+57
-20
lines changed

test.bats

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/usr/bin/env bats
22

3+
run_only_test() {
4+
if [ "$BATS_TEST_NUMBER" -ne "$1" ]; then
5+
skip
6+
fi
7+
}
38

49
setup() {
510
export SLS_DEBUG=t
@@ -14,6 +19,7 @@ setup() {
1419
if [ -d "${USR_CACHE_DIR}" ] ; then
1520
rm -Rf "${USR_CACHE_DIR}"
1621
fi
22+
# run_only_test 42
1723
}
1824

1925
teardown() {
@@ -146,22 +152,22 @@ teardown() {
146152
test $(find puck -type d -name "*.egg-info*" | wc -l) -eq 0
147153
}
148154

149-
@test "py3.6 uses download cache with useDownloadCache option" {
150-
cd tests/base
151-
npm i $(npm pack ../..)
152-
perl -p -i'.bak' -e 's/(pythonRequirements:$)/\1\n useDownloadCache: true/' serverless.yml
153-
sls package
154-
USR_CACHE_DIR=`node -e 'console.log(require("../../lib/shared").getUserCachePath())'`
155-
ls $USR_CACHE_DIR/downloadCacheslspyc/http
156-
}
157-
158-
@test "py3.6 uses download cache with cacheLocation option" {
159-
cd tests/base
160-
npm i $(npm pack ../..)
161-
perl -p -i'.bak' -e 's/(pythonRequirements:$)/\1\n useDownloadCache: true\n cacheLocation: .requirements-cache/' serverless.yml
162-
sls package
163-
ls .requirements-cache/downloadCacheslspyc/http
164-
}
155+
# @test "py3.6 uses download cache with useDownloadCache option" {
156+
# cd tests/base
157+
# npm i $(npm pack ../..)
158+
# perl -p -i'.bak' -e 's/(pythonRequirements:$)/\1\n useDownloadCache: true/' serverless.yml
159+
# sls package
160+
# USR_CACHE_DIR=`node -e 'console.log(require("../../lib/shared").getUserCachePath())'`
161+
# ls $USR_CACHE_DIR/downloadCacheslspyc/http
162+
# }
163+
164+
# @test "py3.6 uses download cache with cacheLocation option" {
165+
# cd tests/base
166+
# npm i $(npm pack ../..)
167+
# perl -p -i'.bak' -e 's/(pythonRequirements:$)/\1\n useDownloadCache: true\n cacheLocation: .requirements-cache/' serverless.yml
168+
# sls package
169+
# ls .requirements-cache/downloadCacheslspyc/http
170+
# }
165171

166172
@test "py3.6 uses download cache with dockerizePip option" {
167173
cd tests/base

test.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const deasync = require('deasync-promise');
33
const glob = require('glob-all');
44
const JSZip = require('jszip');
55
const tape = require('tape');
6-
const { removeSync, readFileSync } = require('fs-extra');
6+
const { removeSync, readFileSync, pathExistsSync } = require('fs-extra');
77
const { sep } = require('path');
88

99
const { getUserCachePath } = require('./lib/shared');
@@ -501,6 +501,35 @@ test('can package individually, moving modules to root of zip-File with Individu
501501
t.end();
502502
});
503503

504+
test('py3.6 uses download cache with useDownloadCache option', t => {
505+
process.chdir('tests/base');
506+
const path = npm(['pack', '../..']);
507+
npm(['i', path]);
508+
sls(['--useDownloadCache=true', 'package']);
509+
510+
const cachepath = getUserCachePath()
511+
t.true(
512+
pathExistsSync(`${cachepath}${sep}downloadCacheslspyc${sep}http`),
513+
'cache directoy exists'
514+
);
515+
516+
t.end();
517+
});
518+
519+
test('py3.6 uses download cache with cacheLocation option', t => {
520+
process.chdir('tests/base');
521+
const path = npm(['pack', '../..']);
522+
npm(['i', path]);
523+
sls(['--useDownloadCache=true', '--cacheLocation=.requirements-cache', 'package']);
524+
525+
t.true(
526+
pathExistsSync(`.requirements-cache${sep}downloadCacheslspyc${sep}http`),
527+
'cache directoy exists'
528+
);
529+
530+
t.end();
531+
});
532+
504533
/*
505534
* News tests not in test.bats
506535
*/

tests/base/serverless.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ custom:
1717
IndividuallyMoveUpModules: ${opt:moveup, self:custom.defaults.IndividuallyMoveUpModules}
1818
useStaticCache: ${opt:useStaticCache, self:custom.defaults.useStaticCache}
1919
useDownloadCache: ${opt:useDownloadCache, self:custom.defaults.useDownloadCache}
20+
cacheLocation: ${opt:cacheLocation, self:custom.defaults.cacheLocation}
2021
defaults:
2122
slim: false
2223
slimPatterns: false
@@ -26,6 +27,7 @@ custom:
2627
IndividuallyMoveUpModules: true
2728
useStaticCache: false
2829
useDownloadCache: false
30+
cacheLocation: ''
2931

3032
package:
3133
individually: ${opt:individually, self:custom.defaults.individually}
@@ -53,12 +55,12 @@ functions:
5355
module: fn2
5456
package:
5557
include:
56-
- 'fn2/**'
58+
- 'fn2/**'
5759
- 'common/__init__.py'
5860
hello6:
5961
handler: fn3.fn3_handler.hello
6062
module: fn3
6163
package:
6264
include:
63-
- 'fn3/**'
64-
- 'common/__init__.py'
65+
- 'fn3/**'
66+
- 'common/__init__.py'

0 commit comments

Comments
 (0)