UNPKG

apigeelint

Version:

Node module and tool to lint a bundle for an Apigee API Proxy or sharedflow.

66 lines (56 loc) 1.9 kB
/* Copyright © 2019-2026 Google LLC 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 https://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. */ const assert = require("node:assert"), path = require("node:path"), Bundle = require("../../lib/package/Bundle.js"); describe("addMessage", function () { it("Should add a message for 'undefined' proxies", function () { const proxyPath = path.resolve( __dirname, "../fixtures/resources/newBundle/apiproxy", ); const configuration = { debug: true, source: { type: "filesystem", path: proxyPath, sourcePath: proxyPath, bundleType: "apiproxy", }, profile: "apigee", excluded: {}, setExitCode: false, output: () => {}, // suppress output }; const message = "This is a test"; const plugin = { ruleId: "TR001", severity: 1, // 1=warning nodeType: "Bundle", }; const bundle = new Bundle(configuration); bundle.addMessage({ plugin, message }); bundle.getReport((report) => { const bundleResult = report.find( (element) => path.normalize(element.filePath) === path.normalize(proxyPath), ); assert.ok(bundleResult); assert.equal(bundleResult.warningCount, 1); const m = bundleResult.messages.find( (element) => element.message === message, ); assert.equal(m.ruleId, plugin.ruleId); }); }); });