Skip to content

Commit

Permalink
fixed download bug and added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
da1nerd committed Oct 25, 2016
1 parent 1600286 commit 387aa99
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ out/
node_modules/
*.tgz
npm-debug.log
build/
build/
mocha_tests/out
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
*.tgz
out
out
mocha_tests
3 changes: 2 additions & 1 deletion __tests__/main-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ describe('Client', () => {
fs.writeFileSync(archiveFile, 'some file');
mkdirp(archiveDir);

let rc = require('resource-container');

expect(fileUtils.fileExists(archiveFile)).toBeTruthy();
expect(fileUtils.fileExists(archiveDir)).toBeTruthy();

Expand All @@ -251,7 +253,6 @@ describe('Client', () => {
]
};


return client.legacy_tools.downloadFutureCompatibleResourceContainer('en', 'obs', 'obs')
.then(() => {
expect(request.download.mock.calls.length).toEqual(1);
Expand Down
2 changes: 1 addition & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ function Client(dbPath, resourceDir, opts) {
if(!containerFormat) throw new Error('Unknown resource format');
containerFormat.imported = 0;
resource.formats = [containerFormat];
library.public_getters.addResource(resource, resource.project_id);
library.addResource(resource, resource.project_id);

let data = fs.readFileSync(path, {encoding: 'utf8'});

Expand Down
19 changes: 19 additions & 0 deletions mocha_tests/download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var rimraf = require('rimraf');
var mkdirp = require('mkdirp');
var assert = require('assert');
describe('Download', function() {
let client;

beforeEach(function() {
rimraf.sync('mocha_tests/out');
let Door43Client = require('../');
client = new Door43Client('mocha_tests/index.sqlite', 'mocha_tests/out/containers');
});

describe('download container', function() {
this.timeout(10000);
it('should download a resource container successfully', function() {
return client.downloadResourceContainer('en', 'gen', 'ulb');
});
});
});
Binary file added mocha_tests/index.sqlite
Binary file not shown.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "door43-client",
"version": "0.7.7",
"version": "0.8.0",
"description": "A client library for interacting with the Door43 Resource API.",
"main": "./lib/main.js",
"scripts": {
"test": "jest"
"test": "jest; mocha mocha_tests/*.js"
},
"repository": {
"type": "git",
Expand All @@ -20,7 +20,7 @@
"gulp": "^3.9.1",
"gulp-mocha": "^2.2.0",
"jest": "^13.2.3",
"mocha": "^2.4.5",
"mocha": "^2.5.3",
"yargs": "^4.8.0"
},
"bin": {
Expand All @@ -35,7 +35,7 @@
"mkdirp": "^0.5.1",
"mv": "^2.1.1",
"ncp": "^2.0.0",
"resource-container": "^0.10.3",
"resource-container": "^0.11.0",
"rimraf": "^2.5.3",
"sql.js": "^0.2.21",
"tar-fs": "^1.13.0",
Expand Down

0 comments on commit 387aa99

Please sign in to comment.