Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from apigee-internal/custom-config-path
Adding support for setting a custom config directory.
- Loading branch information
Showing
7 changed files
with
120 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const assert = require('assert'); | ||
const locations = require('../config/locations'); | ||
const init = require('../cli/lib/init'); | ||
const fs = require('fs'); | ||
|
||
//these are needed to account for the mutation of a singleton pathing module | ||
const path = require('path'); | ||
const normalizedPath = path.normalize(__dirname); | ||
|
||
describe('configure', () => { | ||
describe('init module', () => { | ||
it('will copy file to custom dir', (done) => { | ||
init({configDir: 'foo'}, (err, file) => { | ||
assert.equal(file, 'foo/default.yaml'); | ||
|
||
const fileBuf = fs.readFileSync('config/default.yaml'); | ||
const testBuf = fs.readFileSync(file); | ||
assert.equal(fileBuf.toString(), testBuf.toString()); | ||
done(); | ||
}); | ||
}); | ||
it('will copy file to default dir', () => { | ||
init({}, (err, file) => { | ||
console.log(file); | ||
assert.equal(file, path.join(normalizedPath, 'default.yaml')); | ||
|
||
const fileBuf = fs.readFileSync('config/default.yaml'); | ||
const testBuf = fs.readFileSync(file); | ||
assert.equal(fileBuf.toString(), testBuf.toString()); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
describe('locations module', () => { | ||
it('will build a source path without a configDir', () => { | ||
var configPath = locations.getSourcePath('test', 'foo'); | ||
//This path differs from the actual config path because we mutate the singleton in other tests. | ||
assert.equal(configPath, path.join(normalizedPath, 'test-foo-config.yaml')); | ||
}); | ||
it('will build a source path with a configDir', () => { | ||
var configPath = locations.getSourcePath('test', 'foo', 'foo'); | ||
assert.equal(configPath, 'foo/test-foo-config.yaml'); | ||
}); | ||
it('will build a cache path without a configDir', () => { | ||
var cachePath = locations.getCachePath('test', 'foo'); | ||
//This path differs from the actual config path because we mutate the singleton in other tests. | ||
assert.equal(cachePath, path.join(normalizedPath, 'test-foo-cache-config.yaml')); | ||
}); | ||
it('will build a cache path with a configDir', () => { | ||
var cachePath = locations.getCachePath('test', 'foo', 'foo'); | ||
assert.equal(cachePath, 'foo/test-foo-cache-config.yaml'); | ||
}); | ||
it('will put together a properly named source file', () => { | ||
var sourceFile = locations.getSourceFile('test', 'foo'); | ||
assert.equal(sourceFile, 'test-foo-config.yaml'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters