Skip to content

Commit

Permalink
chore(test): add a test to make sure the instantiate binary api works…
Browse files Browse the repository at this point in the history
… as inteded. (#213)

There was an issue with an underlying module, and how it was merging things.  This test makes sure it doesn't break again.
  • Loading branch information
lholmquist committed May 5, 2020
1 parent 308cf54 commit 1277302
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/binary-build-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

const test = require('tape');
const nock = require('nock');
const fs = require('fs');

const openshiftRestClient = require('../');
const userDefinedConfig = require('./test-config.json');

// There was an issue with some underlying dependecies that made this api break
// but not any others.
test('instantiateBinary - buildconfig', async (t) => {
openshiftRestClient.config.loadFromString(JSON.stringify(userDefinedConfig));
const settings = {
config: openshiftRestClient.config
};

const client = await openshiftRestClient.OpenshiftClient(settings);
const buildConfigName = 'cool-buildconfig-name-1';
const namespace = 'for-node-client-testing';

nock('https://192.168.99.100:8443')
.matchHeader('authorization', 'Bearer zVBd1ZFeJqEAILJgimm4-gZJauaw3PW4EVqV_peEZ3U')
.post(`/apis/build.openshift.io/v1/namespaces/for-node-client-testing/buildconfigs/${buildConfigName}/instantiatebinary`)
.reply(201, { kind: 'BinaryBuildRequest' });

const binaryResponse = await client.apis.build.v1.ns(namespace).buildconfigs(buildConfigName).instantiatebinary.post({ body: fs.createReadStream(`${__dirname}/test-config`), json: false });
const response = JSON.parse(binaryResponse.body);

t.equal(response.kind, 'BinaryBuildRequest', 'returns an object with BinaryBuildRequest');
t.end();
});

0 comments on commit 1277302

Please sign in to comment.