Skip to content

Commit

Permalink
grafanaText not mandatory when updating an existing annotation
Browse files Browse the repository at this point in the history
grafanaText should only be mandatory when a new annotation is created
  • Loading branch information
hexionas authored Sep 28, 2023
2 parents c4c1c01 + 09b6c9e commit f171497
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const run = () => {
const grafanaTags = core.getInput("grafanaTags").split("\n").filter(x => x !== "");
const grafanaDashboardID = Number.parseInt(core.getInput("grafanaDashboardID"), 10) || undefined;
const grafanaPanelID = Number.parseInt(core.getInput("grafanaPanelID"),10) || undefined;
const grafanaText = core.getInput("grafanaText", {required: true});
const grafanaAnnotationID = Number.parseInt(core.getInput("grafanaAnnotationID"), 10) || undefined;
const grafanaText = core.getInput("grafanaText", {required: (grafanaAnnotationID === undefined)});

let headers = {
"Content-Type": "application/json",
Expand Down Expand Up @@ -94,4 +94,4 @@ export const run = () => {
}
};

run();
run();
1 change: 1 addition & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe('Grafana Annotation Action Tests', () => {
// ****************************************************************************************
test('Update Annotation: update', () => {
process.env.INPUT_GRAFANAANNOTATIONID = "12345";
delete process.env.INPUT_GRAFANATEXT; // Make sure text is not present
axios.patch.mockImplementation(() => Promise.resolve({ status: 200}));
run();
expect(axios.post).toBeCalledTimes(0);
Expand Down

0 comments on commit f171497

Please sign in to comment.