-
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 #83 from yashkohli88/yk/notices-tests
Expanded Integration Test suite with New Test Cases for Notices API
- Loading branch information
Showing
4 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
tools/integration/test/integration/e2e-test-service/noticeTest.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,59 @@ | ||
// (c) Copyright 2024, SAP SE and ClearlyDefined contributors. Licensed under the MIT license. | ||
// SPDX-License-Identifier: MIT | ||
|
||
const { deepStrictEqual } = require('assert') | ||
const { callFetch, buildPostOpts } = require('../../../lib/fetch') | ||
const { devApiBaseUrl, prodApiBaseUrl, components, definition } = require('../testConfig') | ||
const nock = require('nock') | ||
const fs = require('fs') | ||
|
||
describe('Validate notice files between dev and prod', function () { | ||
this.timeout(definition.timeout) | ||
|
||
//Rest a bit to avoid overloading the servers | ||
afterEach(() => new Promise(resolve => setTimeout(resolve, definition.timeout / 2))) | ||
|
||
before(() => { | ||
loadFixtures().forEach(([coordinatesString, notice]) => { | ||
nock(prodApiBaseUrl, { allowUnmocked: true }) | ||
.post('/notices', { coordinates: [coordinatesString] }) | ||
.reply(200, notice) | ||
}) | ||
}) | ||
|
||
components.forEach(coordinates => { | ||
it(`should return the same notice as prod for ${coordinates}`, () => fetchAndCompareNotices(coordinates)) | ||
}) | ||
}) | ||
|
||
async function fetchAndCompareNotices(coordinates) { | ||
const [computedNotice, expectedNotice] = await Promise.all( | ||
[ | ||
callFetch( | ||
`${devApiBaseUrl}/notices`, | ||
buildPostOpts({ | ||
coordinates: [coordinates] | ||
}) | ||
), | ||
callFetch( | ||
`${prodApiBaseUrl}/notices`, | ||
buildPostOpts({ | ||
coordinates: [coordinates] | ||
}) | ||
) | ||
].map(p => p.then(r => r.json())) | ||
) | ||
deepStrictEqual(computedNotice, expectedNotice) | ||
} | ||
|
||
function loadFixtures() { | ||
const location = 'test/integration/fixtures/notices' | ||
return fs | ||
.readdirSync(location) | ||
.filter(f => f.endsWith('.json')) | ||
.map(jsonFile => { | ||
const notice = JSON.parse(fs.readFileSync(`${location}/${jsonFile}`)) | ||
const coordinatesString = jsonFile.replaceAll('-', '/').replaceAll('///', '/-/').replace('.json', '') | ||
return [coordinatesString, notice] | ||
}) | ||
} |
11 changes: 11 additions & 0 deletions
11
tools/integration/test/integration/fixtures/notices/crate-cratesio---ratatui-0.26.0.json
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,11 @@ | ||
{ | ||
"content": "** ratatui; version 0.26.0 -- https://ratatui.rs\nCopyright (c) 2016-2022 Florian Dehau\nCopyright (c) 2023 The Ratatui Developers\n\nThe MIT License (MIT)\n\nCopyright (c) 2016-2022 Florian Dehau\nCopyright (c) 2023 The Ratatui Developers\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n", | ||
"summary": { | ||
"total": 1, | ||
"warnings": { | ||
"noDefinition": [], | ||
"noLicense": [], | ||
"noCopyright": [] | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
tools/integration/test/integration/fixtures/notices/pypi-pypi---sdbus-0.12.0.json
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,11 @@ | ||
{ | ||
"content": "** sdbus; version 0.12.0 -- \nCopyright (C) 2022 igo95862\nCopyright (C) 2023 igo95862\nCopyright (C) 2024 igo95862\nCopyright (c) 2022 igo95862\nCopyright (c) 2023 igo95862\nCopyright (c) 2024 igo95862\nCopyright (C) 2020-2022 igo95862\nCopyright (C) 2020-2023 igo95862\nCopyright (C) 2020-2024 igo95862\nCopyright (c) 2020-2022 igo95862\nCopyright (c) 2020-2023 igo95862\nCopyright (c) 2020-2024 igo95862\nCopyright (C) 2020, 2021 igo95862\nCopyright (c) 2020, 2021 igo95862\ncopyrighted by the Free Software Foundation\nCopyright (c) 1989, 1991 Free Software Foundation, Inc.\nCopyright (c) 1991, 1999 Free Software Foundation, Inc.\n\nGPL-2.0 AND LGPL-2.0-or-later AND LGPL-2.1-or-later", | ||
"summary": { | ||
"total": 1, | ||
"warnings": { | ||
"noDefinition": [], | ||
"noLicense": [], | ||
"noCopyright": [] | ||
} | ||
} | ||
} |
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