Skip to content

Commit

Permalink
run cli, static, and dynamic tests on CI, add tests for cache busting
Browse files Browse the repository at this point in the history
  • Loading branch information
amilajack committed Jan 18, 2019
1 parent db0a79d commit c5934e3
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 7 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.rs]
indent_size = 4

[*.toml]
indent_size = 4

[*.md]
trim_trailing_whitespace = false
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ before_install:
- nvm use ${TRAVIS_NODE_VERSION}
- node -v
- npm -v
- npm install --prefix cli
- npm install --prefix test/cli
- npm install --prefix test/dynamic

addons:
apt:
Expand All @@ -39,8 +42,12 @@ addons:
packages:
- g++-4.8

script: |
cargo test --release -- --nocapture
script:
- cargo test --release -- --nocapture
- npm test --prefix cli
- npm test --prefix test/cli
- npm test --prefix test/dynamic
- cargo test --manifest-path=test/static/Cargo.toml

jobs:
include:
Expand Down
6 changes: 3 additions & 3 deletions test/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@types/inquirer": "0.0.35",
"@types/mkdirp": "^0.5.1",
"@types/mocha": "^5.2.0",
"@types/node": "^8.0.28",
"@types/node": "^8.10.39",
"@types/rimraf": "^2.0.2",
"@types/rsvp": "^3.3.1",
"@types/semver": "^5.3.31",
Expand All @@ -49,7 +49,7 @@
"typescript": "^2.2.2"
},
"scripts": {
"test": "mocha lib/acceptance",
"test": "npm run transpile && mocha lib/**/*.js",
"transpile": "tsc"
}
}
77 changes: 77 additions & 0 deletions test/cli/src/unit/cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { expect } from 'chai';
import BuildSettings from '../../../../cli/lib/build-settings';

describe('build settings', () => {
const env = {
npm_config_target: null,
npm_config_arch: null,
npm_config_target_arch: null,
npm_config_disturl: null,
npm_config_runtime: null,
npm_config_build_from_source: null,
npm_config_devdir: null
};

describe('match', () => {
it('should not match build settings if nodeVersion is different', () => {
const buildSettings = new BuildSettings('rustc-version', 'v11.8.0', env);
const otherSettings = new BuildSettings('rustc-version', 'v10.8.0', env);
expect(buildSettings.match(otherSettings)).equal(false);
});

it('should match build settings if nodeVersion is same', () => {
const buildSettings = new BuildSettings('rustc-version', 'v11.8.0', env);
const otherSettings = new BuildSettings('rustc-version', 'v11.8.0', env);
expect(buildSettings.match(otherSettings)).equal(true);
});

it('should not match against current build settings when nodeVersion is null', () => {
const buildSettings = BuildSettings.current();
const otherSettings = new BuildSettings('rustc-version', null, env);
expect(buildSettings.match(otherSettings)).equal(false);
})
});

describe('serialize', () => {
it('should work when nodeVersion is null', () => {

})
})

describe('current build settings', () => {
it('should return values of expected types', () => {
// @ts-ignore
const { nodeVersion, env, rustc } = BuildSettings.current();
expect(nodeVersion).to.be.a('string');
expect(rustc).to.be.a('string');
expect(env).to.deep.equal({
npm_config_target: process.env.npm_config_target || null,
npm_config_arch: process.env.npm_config_arch || null,
npm_config_target_arch: process.env.npm_config_target_arch || null,
npm_config_disturl: process.env.npm_config_disturl || null,
npm_config_runtime: process.env.npm_config_runtime || null,
npm_config_build_from_source: process.env.npm_config_build_from_source || null,
npm_config_devdir: process.env.npm_config_devdir || null
});
});
});

describe('get node version', () => {
it('should return a string', () => {
expect(BuildSettings.getNodeVersion()).to.be.a('string');
});
});

describe('serialize and deserialize', () => {
it('should be equal when nodeVersion is null', () => {
expect(JSON.stringify(BuildSettings.fromJSON({
rustc: 'rustc-version',
env
}))).equal(JSON.stringify(new BuildSettings(
'rustc-version',
null,
env
).toJSON()));
});
})
});

0 comments on commit c5934e3

Please sign in to comment.