|
| 1 | +var semaphore = require('../../lib/services/semaphore2x') |
| 2 | + |
| 3 | +describe('Semaphore 2.x CI Provider', function() { |
| 4 | + var OLD_ENV = process.env |
| 5 | + |
| 6 | + beforeEach(function() { |
| 7 | + process.env = Object.assign({}, OLD_ENV) |
| 8 | + }) |
| 9 | + |
| 10 | + afterEach(function() { |
| 11 | + process.env = Object.assign({}, OLD_ENV) |
| 12 | + }) |
| 13 | + |
| 14 | + it('can detect semaphore 2x', function() { |
| 15 | + process.env.SEMAPHORE = 'true' |
| 16 | + process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf' |
| 17 | + expect(semaphore.detect()).toBe(true) |
| 18 | + }) |
| 19 | + |
| 20 | + it('does not detect semaphore 1.x', function() { |
| 21 | + process.env.SEMAPHORE = 'true' |
| 22 | + process.env.SEMAPHORE_REPO_SLUG = 'owner/repo' |
| 23 | + expect(semaphore.detect()).toBe(false) |
| 24 | + }) |
| 25 | + |
| 26 | + it('can get semaphore env info', function() { |
| 27 | + process.env.SEMAPHORE_GIT_BRANCH = 'development' |
| 28 | + process.env.SEMAPHORE_GIT_SHA = '5c84719708b9b649b9ef3b56af214f38cee6acde' |
| 29 | + process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf' |
| 30 | + expect(semaphore.configuration()).toEqual({ |
| 31 | + service: 'semaphore2x', |
| 32 | + branch: 'development', |
| 33 | + build: '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf', |
| 34 | + commit: '5c84719708b9b649b9ef3b56af214f38cee6acde', |
| 35 | + }) |
| 36 | + }) |
| 37 | +}) |
0 commit comments