-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
863 additions
and
115 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 was deleted.
Oops, something went wrong.
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,8 @@ | ||
#!/bin/sh | ||
|
||
set echo off | ||
|
||
mkdir -p /opt/apigee/logs && \ | ||
mkdir -p /opt/apigee/plugins && \ | ||
edgemicro init && \ | ||
chmod +x /opt/apigee/entrypoint.sh |
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,3 @@ | ||
#!/bin/sh | ||
set echo off | ||
npm install --only=production --no-optional -g edgemicro |
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,57 @@ | ||
'use strict'; | ||
|
||
const init = require('../cli/lib/init.js'); | ||
const loc = require('../config/locations.js'); | ||
const os = require('os'); | ||
const path = require('path'); | ||
const assert = require('assert'); | ||
const fs = require('fs'); | ||
const edgemicroCustomDir = 'edgemicroCustomDir'; | ||
const edgemicroCustomFilepath = path.join(edgemicroCustomDir, loc.defaultFile); | ||
|
||
describe('init module', () => { | ||
|
||
before((done) => { | ||
try{ | ||
if(fs.existsSync(edgemicroCustomFilepath)) fs.unlinkSync(edgemicroCustomFilepath); | ||
if(fs.existsSync(edgemicroCustomDir)) fs.rmdirSync(edgemicroCustomDir); | ||
} catch(err){ | ||
console.error(err); | ||
} | ||
done(); | ||
}); | ||
|
||
after( (done) => { | ||
try{ | ||
if(fs.existsSync(edgemicroCustomFilepath)) fs.unlinkSync(edgemicroCustomFilepath); | ||
if(fs.existsSync(edgemicroCustomDir)) fs.rmdirSync(edgemicroCustomDir); | ||
} catch(err){ | ||
console.error(err); | ||
} | ||
done(); | ||
}); | ||
|
||
it('creates init config file in default home directory', (done) => { | ||
init({}, (err, location) => { | ||
assert.equal(err, null); | ||
assert.deepStrictEqual(loc.getDefaultPath(), location); | ||
let srcFile = fs.readFileSync(loc.getDefaultPath(), 'utf8'); | ||
let destFile = fs.readFileSync(location, 'utf8'); | ||
assert.deepStrictEqual(srcFile, destFile); | ||
done(); | ||
}); | ||
}); | ||
|
||
|
||
it('allows custom directory to store configuration files', (done) => { | ||
init({configDir: edgemicroCustomDir}, (err, location) => { | ||
assert.equal(err, null); | ||
assert.deepStrictEqual(edgemicroCustomFilepath, location); | ||
let srcFile = fs.readFileSync(loc.getDefaultPath(), 'utf8'); | ||
let destFile = fs.readFileSync(location, 'utf8'); | ||
assert.deepStrictEqual(srcFile, destFile); | ||
done(); | ||
}); | ||
}); | ||
|
||
}); |
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,90 @@ | ||
"use strict"; | ||
|
||
const path = require("path"); | ||
const assert = require("assert"); | ||
const os = require("os"); | ||
const locations = require("../config/locations.js"); | ||
const configDir = path.join(__dirname, "../config"); | ||
const defaultFilename = "default.yaml"; | ||
const defaultDirName = '.edgemicro'; | ||
const configPath = path.join(__dirname, "../config", defaultFilename); | ||
|
||
|
||
describe("locations module", () => { | ||
it("provides default directory to save config as (HOME/.edgemicro)", done => { | ||
const expectedDefaultDir = path.join(os.homedir(), defaultDirName); | ||
assert.equal(expectedDefaultDir, locations.homeDir); | ||
done(); | ||
}); | ||
|
||
it("provides default saved config filename", function (done) { | ||
assert.deepStrictEqual(defaultFilename, locations.defaultFile); | ||
done(); | ||
}) | ||
|
||
it('provides default init source directory', done => { | ||
assert.deepStrictEqual(configDir, locations.defaultDir); | ||
done(); | ||
}); | ||
|
||
it("provides default init source config path", done =>{ | ||
const initPath = locations.getInitPath(); | ||
assert.deepStrictEqual(configPath, initPath); | ||
done(); | ||
}); | ||
|
||
it("provides default directory to save config", done => { | ||
assert.equal( | ||
path.join(os.homedir(), defaultDirName, defaultFilename), | ||
locations.getDefaultPath() | ||
); | ||
done(); | ||
}); | ||
|
||
it("sets custom directory path ", done => { | ||
assert.equal( | ||
path.join("../tests/fixtures", defaultFilename), | ||
locations.getDefaultPath("../tests/fixtures") | ||
); | ||
done(); | ||
//below provides absolute path | ||
// path.join(configDir,'../tests/fixtures', defaultFilename)); | ||
}); | ||
|
||
|
||
it("will put together a properly named source file", done => { | ||
var sourceFile = locations.getSourceFile("test", "foo"); | ||
assert.equal( "test-foo-config.yaml", sourceFile); | ||
done(); | ||
}); | ||
|
||
it("will build a source path without a configDir", done => { | ||
var configPath = locations.getSourcePath("test", "foo"); | ||
assert.equal( | ||
path.join(locations.homeDir, "test-foo-config.yaml"), | ||
configPath | ||
); | ||
done(); | ||
}); | ||
|
||
it("will build a source path with a configDir", done => { | ||
var configPath = locations.getSourcePath("test", "foo", "foo"); | ||
assert.equal(configPath, "foo/test-foo-config.yaml"); | ||
done(); | ||
}); | ||
|
||
it("will build a cache path without a configDir", done => { | ||
var cachePath = locations.getCachePath("test", "foo"); | ||
assert.equal( | ||
cachePath, | ||
path.join(locations.homeDir, "test-foo-cache-config.yaml") | ||
); | ||
done(); | ||
}); | ||
|
||
it("will build a cache path with a configDir", done => { | ||
var cachePath = locations.getCachePath("test", "foo", "foo"); | ||
assert.equal(cachePath, "foo/test-foo-cache-config.yaml"); | ||
done(); | ||
}); | ||
}); |
Oops, something went wrong.