chore: Add test for Zabbix API arguments parsing
This commit is contained in:
parent
058ff42b4a
commit
874a22f53a
2 changed files with 46 additions and 5 deletions
23
.idea/workspace.xml
generated
23
.idea/workspace.xml
generated
|
|
@ -4,7 +4,10 @@
|
||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="d7a71994-2699-4ae4-9fd2-ee13b7f33d35" name="Changes" comment="chore: Update IntelliJ workspace and fix Docker image tag in workflow" />
|
<list default="true" id="d7a71994-2699-4ae4-9fd2-ee13b7f33d35" name="Changes" comment="chore: Add dry-run mode and configure logger for operation mode logging">
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/test/zabbix_api_args_parser.test.ts" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
|
@ -53,7 +56,7 @@
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"go.import.settings.migrated": "true",
|
"go.import.settings.migrated": "true",
|
||||||
"javascript.preferred.runtime.type.id": "node",
|
"javascript.preferred.runtime.type.id": "node",
|
||||||
"last_opened_file_path": "//wsl.localhost/Ubuntu/home/ahilbig/git/vcr/zabbix-graphql-api/.forgejo/workflows",
|
"last_opened_file_path": "//wsl.localhost/Ubuntu/home/ahilbig/git/vcr/zabbix-graphql-api/src/test",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
|
|
@ -76,6 +79,7 @@
|
||||||
</component>
|
</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
|
<recent name="\\wsl.localhost\Ubuntu\home\ahilbig\git\vcr\zabbix-graphql-api\src\test" />
|
||||||
<recent name="\\wsl.localhost\Ubuntu\home\ahilbig\git\vcr\zabbix-graphql-api\.forgejo\workflows" />
|
<recent name="\\wsl.localhost\Ubuntu\home\ahilbig\git\vcr\zabbix-graphql-api\.forgejo\workflows" />
|
||||||
<recent name="\\wsl.localhost\Ubuntu\home\ahilbig\git\vcr\zabbix-graphql-api" />
|
<recent name="\\wsl.localhost\Ubuntu\home\ahilbig\git\vcr\zabbix-graphql-api" />
|
||||||
</key>
|
</key>
|
||||||
|
|
@ -117,7 +121,7 @@
|
||||||
<option name="number" value="Default" />
|
<option name="number" value="Default" />
|
||||||
<option name="presentableId" value="Default" />
|
<option name="presentableId" value="Default" />
|
||||||
<updated>1768273021451</updated>
|
<updated>1768273021451</updated>
|
||||||
<workItem from="1768273025985" duration="8988000" />
|
<workItem from="1768273025985" duration="9671000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="chore: Update IntelliJ workspace settings and add GitHub Actions workflow for Docker deployment">
|
<task id="LOCAL-00001" summary="chore: Update IntelliJ workspace settings and add GitHub Actions workflow for Docker deployment">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
|
|
@ -159,7 +163,15 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1768312137448</updated>
|
<updated>1768312137448</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="6" />
|
<task id="LOCAL-00006" summary="chore: Add dry-run mode and configure logger for operation mode logging">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1768312304586</created>
|
||||||
|
<option name="number" value="00006" />
|
||||||
|
<option name="presentableId" value="LOCAL-00006" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1768312304586</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="7" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
|
|
@ -183,6 +195,7 @@
|
||||||
<MESSAGE value="chore: Update IntelliJ workspace settings and add GitHub Actions workflow for Docker deployment" />
|
<MESSAGE value="chore: Update IntelliJ workspace settings and add GitHub Actions workflow for Docker deployment" />
|
||||||
<MESSAGE value="chore: Add missing ".js" extensions to imports and improve Node.js compatibility for dynamic schema loading" />
|
<MESSAGE value="chore: Add missing ".js" extensions to imports and improve Node.js compatibility for dynamic schema loading" />
|
||||||
<MESSAGE value="chore: Update IntelliJ workspace and fix Docker image tag in workflow" />
|
<MESSAGE value="chore: Update IntelliJ workspace and fix Docker image tag in workflow" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="chore: Update IntelliJ workspace and fix Docker image tag in workflow" />
|
<MESSAGE value="chore: Add dry-run mode and configure logger for operation mode logging" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="chore: Add dry-run mode and configure logger for operation mode logging" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
28
src/test/zabbix_api_args_parser.test.ts
Normal file
28
src/test/zabbix_api_args_parser.test.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
import {ParsedArgs, ZabbixWithTagsParams} from "../datasources/zabbix-request.js";
|
||||||
|
|
||||||
|
test("Parse Zabbix Args", () => {
|
||||||
|
let name_pattern = "Test"
|
||||||
|
let input = {
|
||||||
|
name_pattern: name_pattern,
|
||||||
|
tag_deviceType: ["x1", "x2"]
|
||||||
|
}
|
||||||
|
let args = new ParsedArgs(input)
|
||||||
|
expect(args, "name_pattern should be extracted").not.toContain(name_pattern)
|
||||||
|
// @ts-ignore
|
||||||
|
expect("Testwert", "name_pattern should be converted to regex").toMatch(args.name_pattern)
|
||||||
|
expect((<ZabbixWithTagsParams>args.zabbix_params).tags).toContainEqual({
|
||||||
|
"tag": "deviceType",
|
||||||
|
"operator": 1,
|
||||||
|
"value": "x1"
|
||||||
|
})
|
||||||
|
expect((<ZabbixWithTagsParams>args.zabbix_params).tags).toContainEqual({
|
||||||
|
"tag": "deviceType",
|
||||||
|
"operator": 1,
|
||||||
|
"value": "x2"
|
||||||
|
})
|
||||||
|
expect((<ZabbixWithTagsParams>new ParsedArgs({tag_x: "x1"}).zabbix_params).tags).toContainEqual({
|
||||||
|
"tag": "x",
|
||||||
|
"operator": 1,
|
||||||
|
"value": "x1"
|
||||||
|
})
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue