-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into twitch-social
- Loading branch information
Showing
26 changed files
with
2,032 additions
and
1,563 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
Large diffs are not rendered by default.
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
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 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 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 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,61 @@ | ||
'use strict' | ||
|
||
const Joi = require('joi') | ||
const { nonNegativeInteger } = require('../validators') | ||
const { BaseJsonService, NotFound } = require('..') | ||
|
||
// https://help.testspace.com/docs/reference/web-api#list-results | ||
// case_counts|array|The contained cases [passed, failed, na, errored]|counters of result | ||
// session_* fields are for manual runs | ||
// There are instances where the api returns a 200 status code with an empty array | ||
// notably in cases where a space id is used | ||
const schema = Joi.array() | ||
.items( | ||
Joi.object({ | ||
case_counts: Joi.array() | ||
.items(nonNegativeInteger) | ||
.min(4) | ||
.max(4) | ||
.required(), | ||
}) | ||
) | ||
.required() | ||
|
||
// https://help.testspace.com/docs/dashboard/overview-navigate | ||
// Org is owner/account | ||
// Project is generally a repository | ||
// Space is a container, often a branch | ||
module.exports = class TestspaceBase extends BaseJsonService { | ||
static category = 'build' | ||
static defaultBadgeData = { label: 'tests' } | ||
|
||
async fetch({ org, project, space }) { | ||
// https://help.testspace.com/docs/reference/web-api#list-results | ||
const url = `https://${org}.testspace.com/api/projects/${encodeURIComponent( | ||
project | ||
)}/spaces/${space}/results` | ||
return this._requestJson({ | ||
schema, | ||
url, | ||
errorMessages: { | ||
403: 'org not found or not authorized', | ||
404: 'org, project, or space not found', | ||
}, | ||
}) | ||
} | ||
|
||
transformCaseCounts(json) { | ||
if (json.length === 0) { | ||
throw new NotFound({ prettyMessage: 'space not found or results purged' }) | ||
} | ||
|
||
const [ | ||
{ | ||
case_counts: [passed, failed, skipped, errored], | ||
}, | ||
] = json | ||
const total = passed + failed + skipped + errored | ||
|
||
return { passed, failed, skipped, errored, total } | ||
} | ||
} |
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,13 @@ | ||
'use strict' | ||
|
||
const { expect } = require('chai') | ||
const { NotFound } = require('..') | ||
const TestspaceBase = require('./testspace-base') | ||
|
||
describe('TestspaceBase', function () { | ||
it('throws NotFound when response is missing space results', function () { | ||
expect(() => TestspaceBase.prototype.transformCaseCounts([])) | ||
.to.throw(NotFound) | ||
.with.property('prettyMessage', 'space not found or results purged') | ||
}) | ||
}) |
Oops, something went wrong.