jenkins: make resourceRef required in JenkinsApi#buildProject
This method is only called in one place outside tests, and the resourceRef is guaranteed to be set there, so we can tighten this typing up a bit to make the value mandatory. This class is not exported by the package, so this can be shipped as a patch change. Signed-off-by: Mike Lewis <mtlewis@users.noreply.github.com>
This commit is contained in:
committed by
Joe Porpeglia
parent
3d15619d49
commit
71f8708f00
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-jenkins-backend': patch
|
||||
---
|
||||
|
||||
Make resourceRef required in JenkinsApi to match usage.
|
||||
@@ -34,6 +34,7 @@ const mockedJenkinsClient = {
|
||||
const mockedJenkins = jenkins as jest.Mocked<any>;
|
||||
mockedJenkins.mockReturnValue(mockedJenkinsClient);
|
||||
|
||||
const resourceRef = 'component:default/example-component';
|
||||
const jobFullName = 'example-jobName/foo';
|
||||
const buildNumber = 19;
|
||||
const jenkinsInfo: JenkinsInfo = {
|
||||
@@ -413,7 +414,7 @@ describe('JenkinsApi', () => {
|
||||
);
|
||||
});
|
||||
it('buildProject', async () => {
|
||||
await jenkinsApi.buildProject(jenkinsInfo, jobFullName);
|
||||
await jenkinsApi.buildProject(jenkinsInfo, jobFullName, resourceRef);
|
||||
|
||||
expect(mockedJenkins).toHaveBeenCalledWith({
|
||||
baseUrl: jenkinsInfo.baseUrl,
|
||||
@@ -431,7 +432,7 @@ describe('JenkinsApi', () => {
|
||||
]);
|
||||
|
||||
await expect(() =>
|
||||
jenkinsApi.buildProject(jenkinsInfo, jobFullName),
|
||||
jenkinsApi.buildProject(jenkinsInfo, jobFullName, resourceRef),
|
||||
).rejects.toThrow(NotAllowedError);
|
||||
});
|
||||
|
||||
@@ -442,7 +443,7 @@ describe('JenkinsApi', () => {
|
||||
},
|
||||
]);
|
||||
|
||||
await jenkinsApi.buildProject(jenkinsInfo, jobFullName);
|
||||
await jenkinsApi.buildProject(jenkinsInfo, jobFullName, resourceRef);
|
||||
expect(mockedJenkins).toHaveBeenCalledWith({
|
||||
baseUrl: jenkinsInfo.baseUrl,
|
||||
headers: jenkinsInfo.headers,
|
||||
@@ -453,7 +454,7 @@ describe('JenkinsApi', () => {
|
||||
|
||||
it('buildProject with crumbIssuer option', async () => {
|
||||
const info: JenkinsInfo = { ...jenkinsInfo, crumbIssuer: true };
|
||||
await jenkinsApi.buildProject(info, jobFullName);
|
||||
await jenkinsApi.buildProject(info, jobFullName, resourceRef);
|
||||
|
||||
expect(mockedJenkins).toHaveBeenCalledWith({
|
||||
baseUrl: jenkinsInfo.baseUrl,
|
||||
|
||||
@@ -139,7 +139,7 @@ export class JenkinsApiImpl {
|
||||
async buildProject(
|
||||
jenkinsInfo: JenkinsInfo,
|
||||
jobFullName: string,
|
||||
resourceRef?: string,
|
||||
resourceRef: string,
|
||||
options?: { token?: string },
|
||||
) {
|
||||
const client = await JenkinsApiImpl.getClient(jenkinsInfo);
|
||||
|
||||
Reference in New Issue
Block a user