UNPKG

@atomist/sdm

Version:

Atomist Software Delivery Machine SDK

107 lines 3.58 kB
"use strict"; /* * Copyright © 2020 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.fakeGoalInvocation = void 0; const string_1 = require("@atomist/automation-client/lib/internal/util/string"); const logger_1 = require("@atomist/automation-client/lib/util/logger"); const LoggingProgressLog_1 = require("../../api-helper/log/LoggingProgressLog"); const preferenceStore_1 = require("../../api/context/preferenceStore"); const skillContext_1 = require("../../api/context/skillContext"); const Goal_1 = require("../../api/goal/Goal"); const environment_1 = require("../../api/goal/support/environment"); const types_1 = require("../../typings/types"); const fakeContext_1 = require("./fakeContext"); /** * Useful testing support * @param {RemoteRepoRef} id * @return {GoalInvocation} */ function fakeGoalInvocation(id, options) { return { credentials: { token: "foobar" }, context: fakeContext_1.fakeContext("T1111"), id, addressChannels: async (m) => { logger_1.logger.info("channels > " + m); }, preferences: preferenceStore_1.NoPreferenceStore, progressLog: new LoggingProgressLog_1.LoggingProgressLog("fake"), goalEvent: fakeSdmGoal(id), goal: fakeGoal("fake goal"), configuration: { sdm: Object.assign({}, options), }, skill: skillContext_1.createSkillContext(fakeContext_1.fakeContext("T1111")), }; } exports.fakeGoalInvocation = fakeGoalInvocation; function fakeSdmGoal(id) { return { uniqueName: "hi", name: "Hello", goalSet: "goal set", registration: "foo", goalSetId: "xuf", ts: 42, provenance: [], preConditions: [], environment: "0-code", fulfillment: { method: "other", registration: "@atomist/sdm", name: "something", }, repo: { name: id.repo, owner: id.owner, providerId: "asdfdas", }, sha: "abc", branch: "master", state: types_1.SdmGoalState.requested, push: { repo: { org: { owner: id.owner, provider: { providerId: "skdfjasd", apiUrl: "https://api.github.com", }, }, name: id.repo, channels: [ { name: "foo", id: "1", team: { id: "T357", }, }, ], }, commits: [{ sha: string_1.guid() }], }, }; } function fakeGoal(name) { return new Goal_1.Goal({ uniqueName: name, displayName: name, environment: environment_1.IndependentOfEnvironment, }); } //# sourceMappingURL=fakeGoalInvocation.js.map