screwdriver-executor-base
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "screwdriver-executor-base", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Base class defining the interface for executor implementations", | ||
@@ -21,3 +21,3 @@ "main": "index.js", | ||
"license": "BSD-3-Clause", | ||
"author": "Dao Lam <d2lam@yahoo-inc.com>", | ||
"author": "Dao Lam <daolam112@gmail.com>", | ||
"contributors": [ | ||
@@ -42,2 +42,2 @@ "Dao Lam <daolam112@gmail.com>", | ||
"dependencies": {} | ||
} | ||
} |
@@ -12,2 +12,29 @@ # executor base | ||
## Extending | ||
```js | ||
class MyExecutor extends Executor { | ||
// Implement the interface | ||
start(config, callback) { | ||
if (config.buildId) { | ||
// do stuff here... | ||
return callback(null); | ||
} | ||
return process.nextTick(() => { | ||
callback(new Error('Error starting executor')); | ||
}); | ||
} | ||
} | ||
const executor = new MyExecutor({}); | ||
executor.start({ | ||
buildId: '4b8d9b530d2e5e297b4f470d5b0a6e1310d29c5e', | ||
jobId: '50dc14f719cdc2c9cb1fb0e49dd2acc4cf6189a0', | ||
pipelineId: 'ccc49349d3cffbd12ea9e3d41521480b4aa5de5f', | ||
container: 'node:4', | ||
scmUrl: 'git@github.com:screwdriver-cd/data-model.git#master' | ||
}, (err) => { | ||
// do something... | ||
}); | ||
``` | ||
## Testing | ||
@@ -14,0 +41,0 @@ |
'use strict'; | ||
const assert = require('chai').assert; | ||
const Executor = require('../index'); | ||
describe('index test', () => { | ||
it('fails', () => { | ||
assert.isTrue(false); | ||
let instance; | ||
beforeEach(() => { | ||
instance = new Executor({ foo: 'bar' }); | ||
}); | ||
afterEach(() => { | ||
instance = null; | ||
}); | ||
it('can create a Executor base class', () => { | ||
assert.instanceOf(instance, Executor); | ||
}); | ||
it('has methods that need to be extended', () => { | ||
assert.throws(instance.start, Error, 'not implemented'); | ||
assert.throws(instance.stop, Error, 'not implemented'); | ||
}); | ||
it('can be extended', (done) => { | ||
class Foo extends Executor { | ||
get(id, callback) { | ||
if (id > 0) { | ||
return callback(null, { id }); | ||
} | ||
return process.nextTick(() => { | ||
callback(new Error('invalid id')); | ||
}); | ||
} | ||
} | ||
const bar = new Foo({ foo: 'bar' }); | ||
assert.instanceOf(bar, Executor); | ||
bar.get(1, (err, data) => { | ||
assert.isNull(err); | ||
assert.equal(data.id, 1); | ||
done(); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
9384
82
59