-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from qtomlinson/qt/add_status_test
Add more integration tests for StatusService and StatsService
- Loading branch information
Showing
3 changed files
with
103 additions
and
1 deletion.
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
50 changes: 50 additions & 0 deletions
50
tools/integration/test/integration/e2e-test-service/statsTest.js
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,50 @@ | ||
// (c) Copyright 2024, SAP SE and ClearlyDefined contributors. Licensed under the MIT license. | ||
// SPDX-License-Identifier: MIT | ||
|
||
const { callFetch } = require('../../../lib/fetch') | ||
const { devApiBaseUrl, definition } = require('../testConfig') | ||
const { ok } = require('assert') | ||
|
||
describe('Test for StatsService', function () { | ||
this.timeout(definition.timeout * 10) | ||
|
||
//Rest a bit to avoid overloading the servers | ||
afterEach(() => new Promise(resolve => setTimeout(resolve, definition.timeout))) | ||
|
||
it('should retrieve the list of supported stats', async function () { | ||
const url = `${devApiBaseUrl}/stats` | ||
const result = await callFetch(url).then(r => r.json()) | ||
const expected = [ | ||
'total', | ||
'conda', | ||
'condasrc', | ||
'crate', | ||
'gem', | ||
'git', | ||
'maven', | ||
'npm', | ||
'nuget', | ||
'pod', | ||
'composer', | ||
'pypi', | ||
'deb', | ||
'debsrc' | ||
] | ||
ok(result.length === expected.length) | ||
expected.forEach(e => ok(result.includes(e))) | ||
}) | ||
|
||
it('should retrieve stats for total', async function () { | ||
const url = `${devApiBaseUrl}/stats/total` | ||
const result = await callFetch(url).then(r => r.json()) | ||
ok(result.value.totalCount > 0) | ||
ok(result.value.declaredLicenseBreakdown) | ||
}) | ||
|
||
it('should retrieve stats for composer', async function () { | ||
const url = `${devApiBaseUrl}/stats/composer` | ||
const result = await callFetch(url).then(r => r.json()) | ||
ok(result.value.totalCount > 0) | ||
ok(result.value.declaredLicenseBreakdown) | ||
}) | ||
}) |
45 changes: 45 additions & 0 deletions
45
tools/integration/test/integration/e2e-test-service/statusTest.js
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,45 @@ | ||
// (c) Copyright 2024, SAP SE and ClearlyDefined contributors. Licensed under the MIT license. | ||
// SPDX-License-Identifier: MIT | ||
|
||
const { callFetch } = require('../../../lib/fetch') | ||
const { devApiBaseUrl, definition } = require('../testConfig') | ||
const { ok } = require('assert') | ||
|
||
describe('Test for StatusService', function () { | ||
this.timeout(definition.timeout * 10) | ||
|
||
//Rest a bit to avoid overloading the servers | ||
afterEach(() => new Promise(resolve => setTimeout(resolve, definition.timeout))) | ||
|
||
it('should retrieve the list of supported status queries', async function () { | ||
const url = `${devApiBaseUrl}/status` | ||
const result = await callFetch(url).then(r => r.json()) | ||
const expected = [ | ||
'requestcount', | ||
'definitionavailability', | ||
'processedperday', | ||
'recentlycrawled', | ||
'crawlbreakdown', | ||
'toolsranperday' | ||
] | ||
ok(result.length === expected.length) | ||
expected.forEach(e => ok(result.includes(e))) | ||
}) | ||
|
||
it('should retrieve toolsranperday status via crawler query', async function () { | ||
const url = `${devApiBaseUrl}/status/toolsranperday` | ||
const result = await callFetch(url).then(r => r.json()) | ||
ok(result.length > 0) | ||
ok(result[0].clearlydefined > 0 || result[0].licensee > 0 || result[0].reuse > 0 || result[0].scancode > 0) | ||
}) | ||
|
||
it('should retrieve requestCount status (including today) via service query', async function () { | ||
const url = `${devApiBaseUrl}/status/requestCount` | ||
const result = await callFetch(url).then(r => r.json()) | ||
const sortedDates = Object.keys(result).sort((a, b) => b.localeCompare(a)) | ||
ok(sortedDates.length > 0) | ||
const mostRecentDate = sortedDates[0] | ||
const today = new Date().toISOString().split('T')[0] | ||
ok(mostRecentDate.includes(today)) | ||
}) | ||
}) |