Skip to content

Commit

Permalink
feat(3124): Extend job template steps in pipeline template validation…
Browse files Browse the repository at this point in the history
… [3] (#3135)
  • Loading branch information
tkyi committed Jun 13, 2024
1 parent a73ce46 commit 68d0860
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugins/pipelines/templates/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const boom = require('@hapi/boom');
const schema = require('screwdriver-data-schema');
const templateSchema = schema.api.templateValidator;
const pipelineValidator = require('screwdriver-template-validator').parsePipelineTemplate;
const pipelineValidator = require('screwdriver-template-validator').validatePipelineTemplate;

module.exports = () => ({
method: 'POST',
Expand All @@ -15,8 +15,8 @@ module.exports = () => ({
handler: async (request, h) => {
try {
const { yaml: templateString } = request.payload;

const result = await pipelineValidator(templateString);
const { templateFactory } = request.server.app;
const result = await pipelineValidator(templateString, templateFactory);

return h.response(result);
} catch (err) {
Expand Down
5 changes: 5 additions & 0 deletions test/plugins/pipelines.templates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe('pipeline plugin test', () => {
let bannerMock;
let screwdriverAdminDetailsMock;
let scmMock;
let templateFactoryMock;
let pipelineTemplateFactoryMock;
let pipelineTemplateVersionFactoryMock;
let pipelineTemplateTagFactoryMock;
Expand Down Expand Up @@ -160,6 +161,9 @@ describe('pipeline plugin test', () => {
create: sinon.stub(),
remove: sinon.stub()
};
templateFactoryMock = {
getTemplate: sinon.stub().resolves({ templateId: 1234 })
};
pipelineTemplateVersionFactoryMock = {
create: sinon.stub(),
list: sinon.stub(),
Expand Down Expand Up @@ -192,6 +196,7 @@ describe('pipeline plugin test', () => {
tokenFactory: tokenFactoryMock,
bannerFactory: bannerFactoryMock,
secretFactory: secretFactoryMock,
templateFactory: templateFactoryMock,
pipelineTemplateFactory: pipelineTemplateFactoryMock,
pipelineTemplateVersionFactory: pipelineTemplateVersionFactoryMock,
pipelineTemplateTagFactory: pipelineTemplateTagFactoryMock,
Expand Down

0 comments on commit 68d0860

Please sign in to comment.