Migrated most service tests to use new expectBadge (#3122)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const Joi = require('joi')
|
||||
const { isBuildStatus } = require('../build-status')
|
||||
const t = (module.exports = require('../tester').createServiceTester())
|
||||
|
||||
@@ -9,37 +8,33 @@ const t = (module.exports = require('../tester').createServiceTester())
|
||||
|
||||
t.create('default branch')
|
||||
.get('/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2.json')
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'build',
|
||||
value: isBuildStatus,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'build',
|
||||
message: isBuildStatus,
|
||||
})
|
||||
|
||||
t.create('named branch')
|
||||
.get('/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/2/master.json')
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'build',
|
||||
value: isBuildStatus,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'build',
|
||||
message: isBuildStatus,
|
||||
})
|
||||
|
||||
t.create('unknown definition')
|
||||
.get('/larsbrinkhoff/953a34b9-5966-4923-a48a-c41874cfb5f5/515.json')
|
||||
.expectJSON({ name: 'build', value: 'definition not found' })
|
||||
.expectBadge({ label: 'build', message: 'definition not found' })
|
||||
|
||||
t.create('unknown project')
|
||||
.get('/larsbrinkhoff/foo/515.json')
|
||||
.expectJSON({ name: 'build', value: 'user or project not found' })
|
||||
.expectBadge({ label: 'build', message: 'user or project not found' })
|
||||
|
||||
t.create('unknown user')
|
||||
.get('/notarealuser/foo/515.json')
|
||||
.expectJSON({ name: 'build', value: 'user or project not found' })
|
||||
.expectBadge({ label: 'build', message: 'user or project not found' })
|
||||
|
||||
// The following build definition has always a partially succeeded status
|
||||
t.create('partially succeeded build')
|
||||
.get(
|
||||
'/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/4.json?style=_shields_test'
|
||||
)
|
||||
.expectJSON({ name: 'build', value: 'passing', color: 'orange' })
|
||||
.expectBadge({ label: 'build', message: 'passing', color: 'orange' })
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const Joi = require('joi')
|
||||
const { isIntegerPercentage } = require('../test-validators')
|
||||
const t = (module.exports = require('../tester').createServiceTester())
|
||||
|
||||
@@ -56,25 +55,21 @@ const expCoverageMultipleReports = '77%'
|
||||
|
||||
t.create('default branch coverage')
|
||||
.get(`${uriPrefix}/${linuxDefinitionId}.json`)
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'coverage',
|
||||
value: isIntegerPercentage,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'coverage',
|
||||
message: isIntegerPercentage,
|
||||
})
|
||||
|
||||
t.create('named branch without ref')
|
||||
.get(`${uriPrefix}/${windowsDefinitionId}/init.json`)
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'coverage',
|
||||
value: isIntegerPercentage,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'coverage',
|
||||
message: isIntegerPercentage,
|
||||
})
|
||||
|
||||
t.create('unknown build definition')
|
||||
.get(`${uriPrefix}/${nonExistentDefinitionId}.json`)
|
||||
.expectJSON({ name: 'coverage', value: 'build pipeline not found' })
|
||||
.expectBadge({ label: 'coverage', message: 'build pipeline not found' })
|
||||
|
||||
t.create('404 latest build error response')
|
||||
.get(mockBadgeUriPath)
|
||||
@@ -83,9 +78,9 @@ t.create('404 latest build error response')
|
||||
.get(mockLatestBuildApiUriPath)
|
||||
.reply(404)
|
||||
)
|
||||
.expectJSON({
|
||||
name: 'coverage',
|
||||
value: 'build pipeline or coverage not found',
|
||||
.expectBadge({
|
||||
label: 'coverage',
|
||||
message: 'build pipeline or coverage not found',
|
||||
})
|
||||
|
||||
t.create('no build response')
|
||||
@@ -100,7 +95,7 @@ t.create('no build response')
|
||||
value: [],
|
||||
})
|
||||
)
|
||||
.expectJSON({ name: 'coverage', value: 'build pipeline not found' })
|
||||
.expectBadge({ label: 'coverage', message: 'build pipeline not found' })
|
||||
|
||||
t.create('404 code coverage error response')
|
||||
.get(mockBadgeUriPath)
|
||||
@@ -111,9 +106,9 @@ t.create('404 code coverage error response')
|
||||
.get(mockCodeCoverageApiUriPath)
|
||||
.reply(404)
|
||||
)
|
||||
.expectJSON({
|
||||
name: 'coverage',
|
||||
value: 'build pipeline or coverage not found',
|
||||
.expectBadge({
|
||||
label: 'coverage',
|
||||
message: 'build pipeline or coverage not found',
|
||||
})
|
||||
|
||||
t.create('invalid code coverage response')
|
||||
@@ -125,7 +120,7 @@ t.create('invalid code coverage response')
|
||||
.get(mockCodeCoverageApiUriPath)
|
||||
.reply(200, {})
|
||||
)
|
||||
.expectJSON({ name: 'coverage', value: 'invalid response data' })
|
||||
.expectBadge({ label: 'coverage', message: 'invalid response data' })
|
||||
|
||||
t.create('no code coverage reports')
|
||||
.get(mockBadgeUriPath)
|
||||
@@ -136,7 +131,7 @@ t.create('no code coverage reports')
|
||||
.get(mockCodeCoverageApiUriPath)
|
||||
.reply(200, { coverageData: [] })
|
||||
)
|
||||
.expectJSON({ name: 'coverage', value: '0%' })
|
||||
.expectBadge({ label: 'coverage', message: '0%' })
|
||||
|
||||
t.create('no code coverage reports')
|
||||
.get(mockBadgeUriPath)
|
||||
@@ -147,7 +142,7 @@ t.create('no code coverage reports')
|
||||
.get(mockCodeCoverageApiUriPath)
|
||||
.reply(200, { coverageData: [] })
|
||||
)
|
||||
.expectJSON({ name: 'coverage', value: '0%' })
|
||||
.expectBadge({ label: 'coverage', message: '0%' })
|
||||
|
||||
t.create('no line coverage stats')
|
||||
.get(mockBadgeUriPath)
|
||||
@@ -164,7 +159,7 @@ t.create('no line coverage stats')
|
||||
],
|
||||
})
|
||||
)
|
||||
.expectJSON({ name: 'coverage', value: '0%' })
|
||||
.expectBadge({ label: 'coverage', message: '0%' })
|
||||
|
||||
t.create('single line coverage stats')
|
||||
.get(mockBadgeUriPath)
|
||||
@@ -181,7 +176,7 @@ t.create('single line coverage stats')
|
||||
],
|
||||
})
|
||||
)
|
||||
.expectJSON({ name: 'coverage', value: expCoverageSingleReport })
|
||||
.expectBadge({ label: 'coverage', message: expCoverageSingleReport })
|
||||
|
||||
t.create('mixed line and branch coverage stats')
|
||||
.get(mockBadgeUriPath)
|
||||
@@ -198,7 +193,7 @@ t.create('mixed line and branch coverage stats')
|
||||
],
|
||||
})
|
||||
)
|
||||
.expectJSON({ name: 'coverage', value: expCoverageSingleReport })
|
||||
.expectBadge({ label: 'coverage', message: expCoverageSingleReport })
|
||||
|
||||
t.create('multiple line coverage stat reports')
|
||||
.get(mockBadgeUriPath)
|
||||
@@ -235,7 +230,7 @@ t.create('single JaCoCo style line coverage stats')
|
||||
],
|
||||
})
|
||||
)
|
||||
.expectJSON({ name: 'coverage', value: expCoverageSingleReport })
|
||||
.expectBadge({ label: 'coverage', message: expCoverageSingleReport })
|
||||
|
||||
t.create('mixed JaCoCo style line and branch coverage stats')
|
||||
.get(mockBadgeUriPath)
|
||||
@@ -252,7 +247,7 @@ t.create('mixed JaCoCo style line and branch coverage stats')
|
||||
],
|
||||
})
|
||||
)
|
||||
.expectJSON({ name: 'coverage', value: expCoverageSingleReport })
|
||||
.expectBadge({ label: 'coverage', message: expCoverageSingleReport })
|
||||
|
||||
t.create('multiple JaCoCo style line coverage stat reports')
|
||||
.get(mockBadgeUriPath)
|
||||
@@ -269,4 +264,4 @@ t.create('multiple JaCoCo style line coverage stat reports')
|
||||
],
|
||||
})
|
||||
)
|
||||
.expectJSON({ name: 'coverage', value: expCoverageMultipleReports })
|
||||
.expectBadge({ label: 'coverage', message: expCoverageMultipleReports })
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
const Joi = require('joi')
|
||||
const { isBuildStatus } = require('../build-status')
|
||||
const t = (module.exports = require('../tester').createServiceTester())
|
||||
|
||||
@@ -9,28 +8,32 @@ const t = (module.exports = require('../tester').createServiceTester())
|
||||
|
||||
t.create('release status is succeeded')
|
||||
.get('/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/1/1.json')
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'deployment',
|
||||
value: isBuildStatus,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'deployment',
|
||||
message: isBuildStatus,
|
||||
})
|
||||
|
||||
t.create('unknown environment')
|
||||
.get('/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/1/515.json')
|
||||
.expectJSON({ name: 'deployment', value: 'user or environment not found' })
|
||||
.expectBadge({
|
||||
label: 'deployment',
|
||||
message: 'user or environment not found',
|
||||
})
|
||||
|
||||
t.create('unknown definition')
|
||||
.get('/totodem/8cf3ec0e-d0c2-4fcd-8206-ad204f254a96/515/515.json')
|
||||
.expectJSON({
|
||||
name: 'deployment',
|
||||
value: 'inaccessible or definition not found',
|
||||
.expectBadge({
|
||||
label: 'deployment',
|
||||
message: 'inaccessible or definition not found',
|
||||
})
|
||||
|
||||
t.create('unknown project')
|
||||
.get('/totodem/515/515/515.json')
|
||||
.expectJSON({ name: 'deployment', value: 'project not found' })
|
||||
.expectBadge({ label: 'deployment', message: 'project not found' })
|
||||
|
||||
t.create('unknown user')
|
||||
.get('/this-repo/does-not-exist/1/2.json')
|
||||
.expectJSON({ name: 'deployment', value: 'user or environment not found' })
|
||||
.expectBadge({
|
||||
label: 'deployment',
|
||||
message: 'user or environment not found',
|
||||
})
|
||||
|
||||
@@ -116,7 +116,7 @@ const isCompactCustomAzureDevOpsTestTotals = isAzureDevOpsTestTotals(
|
||||
|
||||
t.create('unknown build definition')
|
||||
.get(`${uriPrefix}/${nonExistentDefinitionId}.json`)
|
||||
.expectJSON({ name: 'tests', value: 'build pipeline not found' })
|
||||
.expectBadge({ label: 'tests', message: 'build pipeline not found' })
|
||||
|
||||
t.create('404 latest build error response')
|
||||
.get(mockBadgeUri)
|
||||
@@ -125,9 +125,9 @@ t.create('404 latest build error response')
|
||||
.get(mockLatestBuildApiUriPath)
|
||||
.reply(404)
|
||||
)
|
||||
.expectJSON({
|
||||
name: 'tests',
|
||||
value: 'build pipeline or test result summary not found',
|
||||
.expectBadge({
|
||||
label: 'tests',
|
||||
message: 'build pipeline or test result summary not found',
|
||||
})
|
||||
|
||||
t.create('no build response')
|
||||
@@ -140,7 +140,7 @@ t.create('no build response')
|
||||
value: [],
|
||||
})
|
||||
)
|
||||
.expectJSON({ name: 'tests', value: 'build pipeline not found' })
|
||||
.expectBadge({ label: 'tests', message: 'build pipeline not found' })
|
||||
|
||||
t.create('no test result summary response')
|
||||
.get(mockBadgeUri)
|
||||
@@ -151,9 +151,9 @@ t.create('no test result summary response')
|
||||
.get(mockTestResultSummaryApiUriPath)
|
||||
.reply(404)
|
||||
)
|
||||
.expectJSON({
|
||||
name: 'tests',
|
||||
value: 'build pipeline or test result summary not found',
|
||||
.expectBadge({
|
||||
label: 'tests',
|
||||
message: 'build pipeline or test result summary not found',
|
||||
})
|
||||
|
||||
t.create('invalid test result summary response')
|
||||
@@ -165,7 +165,7 @@ t.create('invalid test result summary response')
|
||||
.get(mockTestResultSummaryApiUriPath)
|
||||
.reply(200, {})
|
||||
)
|
||||
.expectJSON({ name: 'tests', value: 'invalid response data' })
|
||||
.expectBadge({ label: 'tests', message: 'invalid response data' })
|
||||
|
||||
t.create('no tests in test result summary response')
|
||||
.get(mockBadgeUri)
|
||||
@@ -176,27 +176,23 @@ t.create('no tests in test result summary response')
|
||||
.get(mockTestResultSummaryApiUriPath)
|
||||
.reply(200, mockEmptyTestResultSummaryResponse)
|
||||
)
|
||||
.expectJSON({ name: 'tests', value: 'no tests' })
|
||||
.expectBadge({ label: 'tests', message: 'no tests' })
|
||||
|
||||
t.create('test status')
|
||||
.get(mockBadgeUri)
|
||||
.intercept(mockTestResultSummarySetup)
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'tests',
|
||||
value: expectedDefaultAzureDevOpsTestTotals,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'tests',
|
||||
message: expectedDefaultAzureDevOpsTestTotals,
|
||||
})
|
||||
|
||||
t.create('test status on branch')
|
||||
.get(mockBranchBadgeUri)
|
||||
.intercept(mockBranchTestResultSummarySetup)
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'tests',
|
||||
value: expectedDefaultAzureDevOpsTestTotals,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'tests',
|
||||
message: expectedDefaultAzureDevOpsTestTotals,
|
||||
})
|
||||
|
||||
t.create('test status with compact message')
|
||||
.get(mockBadgeUri, {
|
||||
@@ -205,12 +201,10 @@ t.create('test status with compact message')
|
||||
},
|
||||
})
|
||||
.intercept(mockTestResultSummarySetup)
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'tests',
|
||||
value: expectedCompactAzureDevOpsTestTotals,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'tests',
|
||||
message: expectedCompactAzureDevOpsTestTotals,
|
||||
})
|
||||
|
||||
t.create('test status with custom labels')
|
||||
.get(mockBadgeUri, {
|
||||
@@ -221,12 +215,10 @@ t.create('test status with custom labels')
|
||||
},
|
||||
})
|
||||
.intercept(mockTestResultSummarySetup)
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'tests',
|
||||
value: expectedCustomAzureDevOpsTestTotals,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'tests',
|
||||
message: expectedCustomAzureDevOpsTestTotals,
|
||||
})
|
||||
|
||||
t.create('test status with compact message and custom labels')
|
||||
.get(mockBadgeUri, {
|
||||
@@ -238,24 +230,18 @@ t.create('test status with compact message and custom labels')
|
||||
},
|
||||
})
|
||||
.intercept(mockTestResultSummarySetup)
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'tests',
|
||||
value: expectedCompactCustomAzureDevOpsTestTotals,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'tests',
|
||||
message: expectedCompactCustomAzureDevOpsTestTotals,
|
||||
})
|
||||
|
||||
t.create('live test status')
|
||||
.get(mockBadgeUri)
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({ name: 'tests', value: isDefaultAzureDevOpsTestTotals })
|
||||
)
|
||||
.expectBadge({ label: 'tests', message: isDefaultAzureDevOpsTestTotals })
|
||||
|
||||
t.create('live test status on branch')
|
||||
.get(mockBranchBadgeUri)
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({ name: 'tests', value: isDefaultAzureDevOpsTestTotals })
|
||||
)
|
||||
.expectBadge({ label: 'tests', message: isDefaultAzureDevOpsTestTotals })
|
||||
|
||||
t.create('live test status with compact message')
|
||||
.get(mockBadgeUri, {
|
||||
@@ -263,9 +249,7 @@ t.create('live test status with compact message')
|
||||
compact_message: null,
|
||||
},
|
||||
})
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({ name: 'tests', value: isCompactAzureDevOpsTestTotals })
|
||||
)
|
||||
.expectBadge({ label: 'tests', message: isCompactAzureDevOpsTestTotals })
|
||||
|
||||
t.create('live test status with custom labels')
|
||||
.get(mockBadgeUri, {
|
||||
@@ -275,9 +259,7 @@ t.create('live test status with custom labels')
|
||||
skipped_label: 'n/a',
|
||||
},
|
||||
})
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({ name: 'tests', value: isCustomAzureDevOpsTestTotals })
|
||||
)
|
||||
.expectBadge({ label: 'tests', message: isCustomAzureDevOpsTestTotals })
|
||||
|
||||
t.create('live test status with compact message and custom labels')
|
||||
.get(mockBadgeUri, {
|
||||
@@ -288,9 +270,7 @@ t.create('live test status with compact message and custom labels')
|
||||
skipped_label: '🤷',
|
||||
},
|
||||
})
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'tests',
|
||||
value: isCompactCustomAzureDevOpsTestTotals,
|
||||
})
|
||||
)
|
||||
.expectBadge({
|
||||
label: 'tests',
|
||||
message: isCompactCustomAzureDevOpsTestTotals,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user