Skip to content

Commit

Permalink
Add test cases for Create CustomRuns
Browse files Browse the repository at this point in the history
  • Loading branch information
jisoolee committed Sep 29, 2023
1 parent f942ce4 commit 7b733ac
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 396 deletions.
40 changes: 3 additions & 37 deletions src/api/customRuns.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { deleteRequest, get, patch, post } from './comms';
import {
getQueryParams,
getTektonAPI,
getTektonPipelinesAPIVersion,
removeSystemAnnotations,
removeSystemLabels,
useCollection,
Expand All @@ -43,14 +42,11 @@ function getCustomRunsAPI({ filters, isWebSocket, name, namespace }) {
}

export function getCustomRunPayload({
kind,
labels,
namespace,
nodeSelector,
params,
serviceAccount,
customName,
customRunName = `${customName ? `${customName}-run` : 'run'}-${Date.now()}`,
customRunName = `run-${Date.now()}`,
timeout
}) {
const payload = {
Expand All @@ -63,7 +59,7 @@ export function getCustomRunPayload({
spec: {
customRef: {
apiVersion: '',
kind: 'Custom'
kind: ''
}
}
};
Expand All @@ -76,9 +72,6 @@ export function getCustomRunPayload({
value: params[name]
}));
}
if (nodeSelector) {
payload.spec.podTemplate = { nodeSelector };
}
if (serviceAccount) {
payload.spec.serviceAccountName = serviceAccount;
}
Expand Down Expand Up @@ -158,32 +151,6 @@ export function rerunCustomRun(run) {
return post(uri, payload).then(({ body }) => body);
}

export function createCustomRun({
kind,
labels,
namespace,
nodeSelector,
params,
serviceAccount,
customName,
customRunName = `${customName}-run-${Date.now()}`,
timeout
}) {
const payload = getCustomRunPayload({
kind,
labels,
namespace,
nodeSelector,
params,
serviceAccount,
customName,
customRunName,
timeout
});
const uri = getTektonAPI('customruns', { namespace });
return post(uri, payload).then(({ body }) => body);
}

export function createCustomRunRaw({ namespace, payload }) {
const uri = getTektonAPI('customruns', { namespace, version: 'v1beta1' });
return post(uri, payload).then(({ body }) => body);
Expand All @@ -194,8 +161,7 @@ export function generateNewCustomRunPayload({ customRun, rerun }) {
customRun.metadata;

const payload = deepClone(customRun);
payload.apiVersion =
payload.apiVersion || 'tekton.dev/v1beta1';
payload.apiVersion = payload.apiVersion || 'tekton.dev/v1beta1';
payload.kind = payload.kind || 'CustomRun';

function getGenerateName() {
Expand Down
Loading

0 comments on commit 7b733ac

Please sign in to comment.