1 | var semaphore = require('../../lib/services/semaphore')
|
2 |
|
3 | describe('Semaphore 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', function() {
|
15 | process.env.SEMAPHORE = 'true'
|
16 | process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
|
17 | expect(semaphore.detect()).toBe(true)
|
18 | })
|
19 |
|
20 | it('does not detect semaphore 2.x', function() {
|
21 | process.env.SEMAPHORE = 'true'
|
22 | process.env.SEMAPHORE_WORKFLOW_ID = '65c9bb1c-aeb6-41f0-b8d9-6fa177241cdf'
|
23 | expect(semaphore.detect()).toBe(false)
|
24 | })
|
25 |
|
26 | it('can get semaphore env info', function() {
|
27 | process.env.SEMAPHORE_BUILD_NUMBER = '1234'
|
28 | process.env.REVISION = '5678'
|
29 | process.env.SEMAPHORE_CURRENT_THREAD = '1'
|
30 | process.env.BRANCH_NAME = 'master'
|
31 | process.env.SEMAPHORE_REPO_SLUG = 'owner/repo'
|
32 | expect(semaphore.configuration()).toEqual({
|
33 | service: 'semaphore',
|
34 | commit: '5678',
|
35 | build: '1234.1',
|
36 | branch: 'master',
|
37 | slug: 'owner/repo',
|
38 | })
|
39 | })
|
40 | })
|