Skip to content

Commit

Permalink
Use chai-as-promised to check if functions threw an error
Browse files Browse the repository at this point in the history
  • Loading branch information
KsaweryZietara committed Oct 3, 2024
1 parent 450c9be commit 4d3fffa
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 43 deletions.
63 changes: 42 additions & 21 deletions testing/e2e/skr/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions testing/e2e/skr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"dependencies": {
"@kubernetes/client-node": "0.15.1",
"axios": "^1.7.4",
"chai-as-promised": "^8.0.0",
"js-yaml": "^4.1.0",
"mocha-junit-reporter": "^2.0.0",
"node-forge": "^1.3.1",
Expand Down
27 changes: 5 additions & 22 deletions testing/e2e/skr/skr-binding-test/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const {expect} = require('chai');
const chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
const {gatherOptions} = require('../skr-test');
const {initializeK8sClient} = require('../utils/index.js');
const {getSecret, getKubeconfigValidityInSeconds} = require('../utils');
Expand Down Expand Up @@ -56,23 +58,11 @@ describe('SKR Binding test', function() {
});

it('Try to fetch SKR binding created using Kubernetes TokenRequest', async function() {
try {
await keb.getBinding(options.instanceID, bindingID);
fail('KEB must return an error');
} catch (err) {
expect(err.response.status).equal(404);
console.log('Got response:');
console.log(err.response.data);
}
await expect(keb.getBinding(options.instanceID, bindingID)).to.be.rejectedWith(Error);
});

it('Try to fetch sap-btp-manager secret using binding from Kubernetes TokenRequest', async function() {
try {
await getSecret(secretName, ns);
fail('KCP must return an error');
} catch (err) {
console.log(err);
}
await expect(getSecret(secretName, ns)).to.be.rejectedWith(Error);
});

it('Create SKR binding using Gardener', async function() {
Expand Down Expand Up @@ -104,14 +94,7 @@ describe('SKR Binding test', function() {
});

it('Try to fetch SKR binding created using Gardener', async function() {
try {
await keb.getBinding(options.instanceID, bindingID);
fail('KEB must return an error');
} catch (err) {
expect(err.response.status).equal(404);
console.log('Got response:');
console.log(err.response.data);
}
await expect(keb.getBinding(options.instanceID, bindingID)).to.be.rejectedWith(Error);
});

it('Try to fetch sap-btp-manager secret using binding from Gardener', async function() {
Expand Down

0 comments on commit 4d3fffa

Please sign in to comment.