From e1b211f4ed7ceca8002581b586b27b92b97e3016 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Tue, 14 Nov 2023 15:14:03 +0100 Subject: [PATCH 1/6] try run tests in check-mode, too when a runme.sh exists in the test-path, it will be run. then the roles will be run in check-mode and normal-mode to test if they work in check mode (at least somewhat) --- .../integration/targets/grafana_dashboard/runme.sh | 5 +++++ .../integration/targets/grafana_dashboard/site.yml | 6 ++++++ .../targets/grafana_datasource/runme.sh | 5 +++++ .../targets/grafana_datasource/site.yml | 6 ++++++ tests/integration/targets/grafana_folder/runme.sh | 6 ++++++ tests/integration/targets/grafana_folder/site.yml | 6 ++++++ .../targets/grafana_folder/tasks/main.yml | 4 ++++ .../targets/grafana_notification_channel/runme.sh | 5 +++++ .../targets/grafana_notification_channel/site.yml | 6 ++++++ .../targets/grafana_organization/runme.sh | 6 ++++++ .../targets/grafana_organization/site.yml | 6 ++++++ .../targets/grafana_organization/tasks/main.yml | 11 +++++------ .../targets/grafana_organization_user/runme.sh | 6 ++++++ .../targets/grafana_organization_user/site.yml | 6 ++++++ .../grafana_organization_user/tasks/main.yml | 10 ++++++++++ tests/integration/targets/grafana_team/runme.sh | 5 +++++ tests/integration/targets/grafana_team/site.yml | 6 ++++++ .../targets/grafana_team/tasks/main.yml | 6 +++--- tests/integration/targets/grafana_user/runme.sh | 6 ++++++ tests/integration/targets/grafana_user/site.yml | 6 ++++++ .../targets/grafana_user/tasks/main.yml | 14 ++++++++++++++ 21 files changed, 128 insertions(+), 9 deletions(-) create mode 100755 tests/integration/targets/grafana_dashboard/runme.sh create mode 100644 tests/integration/targets/grafana_dashboard/site.yml create mode 100755 tests/integration/targets/grafana_datasource/runme.sh create mode 100644 tests/integration/targets/grafana_datasource/site.yml create mode 100755 tests/integration/targets/grafana_folder/runme.sh create mode 100644 tests/integration/targets/grafana_folder/site.yml create mode 100755 tests/integration/targets/grafana_notification_channel/runme.sh create mode 100644 tests/integration/targets/grafana_notification_channel/site.yml create mode 100755 tests/integration/targets/grafana_organization/runme.sh create mode 100644 tests/integration/targets/grafana_organization/site.yml create mode 100755 tests/integration/targets/grafana_organization_user/runme.sh create mode 100644 tests/integration/targets/grafana_organization_user/site.yml create mode 100755 tests/integration/targets/grafana_team/runme.sh create mode 100644 tests/integration/targets/grafana_team/site.yml create mode 100755 tests/integration/targets/grafana_user/runme.sh create mode 100644 tests/integration/targets/grafana_user/site.yml diff --git a/tests/integration/targets/grafana_dashboard/runme.sh b/tests/integration/targets/grafana_dashboard/runme.sh new file mode 100755 index 00000000..867afb0d --- /dev/null +++ b/tests/integration/targets/grafana_dashboard/runme.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook site.yml diff --git a/tests/integration/targets/grafana_dashboard/site.yml b/tests/integration/targets/grafana_dashboard/site.yml new file mode 100644 index 00000000..c32364ef --- /dev/null +++ b/tests/integration/targets/grafana_dashboard/site.yml @@ -0,0 +1,6 @@ +--- +- name: Run tests for grafana_dashboard + hosts: localhost + tasks: + - ansible.builtin.include_role: + name: ../../grafana_dashboard diff --git a/tests/integration/targets/grafana_datasource/runme.sh b/tests/integration/targets/grafana_datasource/runme.sh new file mode 100755 index 00000000..867afb0d --- /dev/null +++ b/tests/integration/targets/grafana_datasource/runme.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook site.yml diff --git a/tests/integration/targets/grafana_datasource/site.yml b/tests/integration/targets/grafana_datasource/site.yml new file mode 100644 index 00000000..c8374dcd --- /dev/null +++ b/tests/integration/targets/grafana_datasource/site.yml @@ -0,0 +1,6 @@ +--- +- name: Run tests for grafana_datasource + hosts: localhost + tasks: + - ansible.builtin.include_role: + name: ../../grafana_datasource diff --git a/tests/integration/targets/grafana_folder/runme.sh b/tests/integration/targets/grafana_folder/runme.sh new file mode 100755 index 00000000..9daa487d --- /dev/null +++ b/tests/integration/targets/grafana_folder/runme.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook site.yml --check +ansible-playbook site.yml diff --git a/tests/integration/targets/grafana_folder/site.yml b/tests/integration/targets/grafana_folder/site.yml new file mode 100644 index 00000000..2041400e --- /dev/null +++ b/tests/integration/targets/grafana_folder/site.yml @@ -0,0 +1,6 @@ +--- +- name: Run tests for grafana_folder + hosts: localhost + tasks: + - ansible.builtin.include_role: + name: ../../grafana_folder diff --git a/tests/integration/targets/grafana_folder/tasks/main.yml b/tests/integration/targets/grafana_folder/tasks/main.yml index cada94ab..bee3dc50 100644 --- a/tests/integration/targets/grafana_folder/tasks/main.yml +++ b/tests/integration/targets/grafana_folder/tasks/main.yml @@ -12,6 +12,7 @@ that: - result.changed == true - result.folder.title == 'grafana_working_group' + when: not ansible_check_mode - name: Test folder creation idempotency grafana_folder: @@ -26,6 +27,7 @@ that: - result.changed == false - result.folder.title == 'grafana_working_group' + when: not ansible_check_mode - name: Delete a Folder grafana_folder: @@ -39,6 +41,7 @@ - ansible.builtin.assert: that: - result.changed == true + when: not ansible_check_mode - name: Test folder deletion idempotency grafana_folder: @@ -52,3 +55,4 @@ - ansible.builtin.assert: that: - result.changed == false + when: not ansible_check_mode diff --git a/tests/integration/targets/grafana_notification_channel/runme.sh b/tests/integration/targets/grafana_notification_channel/runme.sh new file mode 100755 index 00000000..867afb0d --- /dev/null +++ b/tests/integration/targets/grafana_notification_channel/runme.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook site.yml diff --git a/tests/integration/targets/grafana_notification_channel/site.yml b/tests/integration/targets/grafana_notification_channel/site.yml new file mode 100644 index 00000000..e20f44e3 --- /dev/null +++ b/tests/integration/targets/grafana_notification_channel/site.yml @@ -0,0 +1,6 @@ +--- +- name: Run tests for grafana_notification_channel + hosts: localhost + tasks: + - ansible.builtin.include_role: + name: ../../grafana_notification_channel diff --git a/tests/integration/targets/grafana_organization/runme.sh b/tests/integration/targets/grafana_organization/runme.sh new file mode 100755 index 00000000..9daa487d --- /dev/null +++ b/tests/integration/targets/grafana_organization/runme.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook site.yml --check +ansible-playbook site.yml diff --git a/tests/integration/targets/grafana_organization/site.yml b/tests/integration/targets/grafana_organization/site.yml new file mode 100644 index 00000000..e2e4900b --- /dev/null +++ b/tests/integration/targets/grafana_organization/site.yml @@ -0,0 +1,6 @@ +--- +- name: Run tests for grafana_organization + hosts: localhost + tasks: + - ansible.builtin.include_role: + name: ../../grafana_organization diff --git a/tests/integration/targets/grafana_organization/tasks/main.yml b/tests/integration/targets/grafana_organization/tasks/main.yml index 156bc940..22f8aa0c 100644 --- a/tests/integration/targets/grafana_organization/tasks/main.yml +++ b/tests/integration/targets/grafana_organization/tasks/main.yml @@ -6,12 +6,8 @@ url_password: "{{ grafana_password }}" name: orgtest state: present - register: result -- ansible.builtin.assert: - that: - - result.changed == true - - result.failed == false - - result.org.name == 'orgtest' + register: result - "result.changed == true" - "result.failed == false" - "result.org.name == 'orgtest'" + when: not ansible_check_mode - name: Check idempotency Grafana organization community.grafana.grafana_organization: @@ -26,6 +22,7 @@ - result.changed == false - result.failed == false - result.org.name == 'orgtest' + when: not ansible_check_mode - name: Delete a Grafana organization community.grafana.grafana_organization: @@ -40,6 +37,7 @@ - result.changed == true - result.failed == false - result.msg |length > 0 + when: not ansible_check_mode - name: Check idempotency delete a Grafana organization community.grafana.grafana_organization: @@ -54,3 +52,4 @@ - result.changed == false - result.failed == false - result.msg == 'No org found, nothing to do' + when: not ansible_check_mode diff --git a/tests/integration/targets/grafana_organization_user/runme.sh b/tests/integration/targets/grafana_organization_user/runme.sh new file mode 100755 index 00000000..9daa487d --- /dev/null +++ b/tests/integration/targets/grafana_organization_user/runme.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook site.yml --check +ansible-playbook site.yml diff --git a/tests/integration/targets/grafana_organization_user/site.yml b/tests/integration/targets/grafana_organization_user/site.yml new file mode 100644 index 00000000..80e5ea91 --- /dev/null +++ b/tests/integration/targets/grafana_organization_user/site.yml @@ -0,0 +1,6 @@ +--- +- name: Run tests for grafana_organization_user + hosts: localhost + tasks: + - ansible.builtin.include_role: + name: ../../grafana_organization_user diff --git a/tests/integration/targets/grafana_organization_user/tasks/main.yml b/tests/integration/targets/grafana_organization_user/tasks/main.yml index 6887670c..a9b46b03 100644 --- a/tests/integration/targets/grafana_organization_user/tasks/main.yml +++ b/tests/integration/targets/grafana_organization_user/tasks/main.yml @@ -23,6 +23,7 @@ that: - result.failed == false - result.changed == true + when: not ansible_check_mode - name: Check idempotency on user removal from org community.grafana.grafana_organization_user: @@ -36,6 +37,7 @@ that: - result.failed == false - result.changed == false + when: not ansible_check_mode - name: Add user to organization community.grafana.grafana_organization_user: @@ -52,6 +54,7 @@ - result.changed == true - result.user.orgId == 1 - result.user.role == 'Viewer' + when: not ansible_check_mode - name: Update existing user role community.grafana.grafana_organization_user: @@ -68,6 +71,7 @@ - result.changed == true - result.user.orgId == 1 - result.user.role == 'Editor' + when: not ansible_check_mode - name: Check idempotency on user update community.grafana.grafana_organization_user: @@ -82,6 +86,7 @@ that: - result.failed == false - result.changed == false + when: not ansible_check_mode - name: Create a new organization community.grafana.grafana_organization: @@ -102,12 +107,14 @@ role: admin state: present register: result +- ansible.builtin.assert: - ansible.builtin.assert: that: - result.failed == false - result.changed == true - result.user.orgId == org.org.id - result.user.role == 'Admin' + when: not ansible_check_mode - name: Remove user from new organization by org_id community.grafana.grafana_organization_user: @@ -122,6 +129,7 @@ that: - result.failed == false - result.changed == true + when: not ansible_check_mode - name: Add user to the new organization by org_name community.grafana.grafana_organization_user: @@ -139,6 +147,7 @@ - result.changed == true - result.user.orgId == org.org.id - result.user.role == 'Admin' + when: not ansible_check_mode - name: Remove user from new organization by org_name community.grafana.grafana_organization_user: @@ -153,3 +162,4 @@ that: - result.failed == false - result.changed == true + when: not ansible_check_mode diff --git a/tests/integration/targets/grafana_team/runme.sh b/tests/integration/targets/grafana_team/runme.sh new file mode 100755 index 00000000..867afb0d --- /dev/null +++ b/tests/integration/targets/grafana_team/runme.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook site.yml diff --git a/tests/integration/targets/grafana_team/site.yml b/tests/integration/targets/grafana_team/site.yml new file mode 100644 index 00000000..c8a61889 --- /dev/null +++ b/tests/integration/targets/grafana_team/site.yml @@ -0,0 +1,6 @@ +--- +- name: Run tests for grafana_team + hosts: localhost + tasks: + - ansible.builtin.include_role: + name: ../../grafana_team diff --git a/tests/integration/targets/grafana_team/tasks/main.yml b/tests/integration/targets/grafana_team/tasks/main.yml index 74fb5c84..41a8cec4 100644 --- a/tests/integration/targets/grafana_team/tasks/main.yml +++ b/tests/integration/targets/grafana_team/tasks/main.yml @@ -4,9 +4,10 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: grafana_working_group + name: grafana working group email: foo.bar@example.com state: present + skip_version_check: true register: result - ansible.builtin.set_fact: @@ -19,7 +20,7 @@ - ansible.builtin.assert: that: - result.changed == true - - result.team.name == 'grafana_working_group' + - result.team.name == 'grafana working group' - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members @@ -173,7 +174,6 @@ - john+doe@example.com - jane.doe@example.com state: present - register: result - ansible.builtin.set_fact: expected_members: "{{ auto_member | ternary(['********@localhost', 'jane.doe@example.com', 'john+doe@example.com'], ['jane.doe@example.com', 'john+doe@example.com']) diff --git a/tests/integration/targets/grafana_user/runme.sh b/tests/integration/targets/grafana_user/runme.sh new file mode 100755 index 00000000..9daa487d --- /dev/null +++ b/tests/integration/targets/grafana_user/runme.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -eux + +ansible-playbook site.yml --check +ansible-playbook site.yml diff --git a/tests/integration/targets/grafana_user/site.yml b/tests/integration/targets/grafana_user/site.yml new file mode 100644 index 00000000..b080803f --- /dev/null +++ b/tests/integration/targets/grafana_user/site.yml @@ -0,0 +1,6 @@ +--- +- name: Run tests for grafana_user + hosts: localhost + tasks: + - ansible.builtin.include_role: + name: ../../grafana_user diff --git a/tests/integration/targets/grafana_user/tasks/main.yml b/tests/integration/targets/grafana_user/tasks/main.yml index 01ded30b..83a3891e 100644 --- a/tests/integration/targets/grafana_user/tasks/main.yml +++ b/tests/integration/targets/grafana_user/tasks/main.yml @@ -18,6 +18,7 @@ - result.user.name == 'Harley Quinn' - result.user.email == 'harley.quinn@gotham.city' - result.user.isGrafanaAdmin == true + when: not ansible_check_mode - name: Check idempotency on admin creation community.grafana.grafana_user: @@ -37,6 +38,7 @@ - result.user.name == 'Harley Quinn' - result.user.email == 'harley.quinn@gotham.city' - result.user.isGrafanaAdmin == true + when: not ansible_check_mode - name: Check user creation with Grafana API ansible.builtin.uri: @@ -54,6 +56,7 @@ - result.json.name == 'Harley Quinn' - result.json.email == 'harley.quinn@gotham.city' - result.json.isGrafanaAdmin == true + when: not ansible_check_mode - name: Create a Grafana user without password (expect failure) community.grafana.grafana_user: @@ -71,6 +74,7 @@ - result.changed == false - result.failed == true - "result.msg == 'missing required arguments: password'" + when: not ansible_check_mode - name: Create a Grafana user community.grafana.grafana_user: @@ -89,6 +93,7 @@ - result.user.name == 'Bruce Wayne' - result.user.email == 'batman@gotham.city' - result.user.isGrafanaAdmin == false + when: not ansible_check_mode - name: Check idempotency on user creation (password not requiered) community.grafana.grafana_user: @@ -106,6 +111,7 @@ - result.user.name == 'Bruce Wayne' - result.user.email == 'batman@gotham.city' - result.user.isGrafanaAdmin == false + when: not ansible_check_mode - name: Check user creation with Grafana API ansible.builtin.uri: @@ -123,6 +129,7 @@ - result.json.name == 'Bruce Wayne' - result.json.email == 'batman@gotham.city' - result.json.isGrafanaAdmin == false + when: not ansible_check_mode - name: Update Grafana user community.grafana.grafana_user: @@ -142,6 +149,7 @@ - result.user.name == 'The Dark Knight' - result.user.email == 'thedarkknight@gotham.city' - result.user.isGrafanaAdmin == true + when: not ansible_check_mode - name: Check user update with Grafana API ansible.builtin.uri: @@ -159,6 +167,7 @@ - result.json.name == 'The Dark Knight' - result.json.email == 'thedarkknight@gotham.city' - result.json.isGrafanaAdmin == true + when: not ansible_check_mode - name: Delete a Grafana user community.grafana.grafana_user: @@ -172,6 +181,7 @@ that: - result.changed == true - result.message == 'User deleted' + when: not ansible_check_mode - name: Check idempotency on user deletion community.grafana.grafana_user: @@ -185,6 +195,7 @@ that: - result.changed == false - result.message == 'No user found, nothing to do' + when: not ansible_check_mode - name: Check user deletion with Grafana API (expect 404 Not Found) ansible.builtin.uri: @@ -200,6 +211,7 @@ - ansible.builtin.assert: that: - result.json.message | lower == 'user not found' + when: not ansible_check_mode - name: Create a Grafana user with character encoding community.grafana.grafana_user: @@ -218,6 +230,7 @@ - result.user.name == 'Bruce Wayne' - result.user.email == 'bruce+wayne@gotham.city' - result.user.isGrafanaAdmin == false + when: not ansible_check_mode - name: Check idempotency on user creation (password not requiered) community.grafana.grafana_user: @@ -235,3 +248,4 @@ - result.user.name == 'Bruce Wayne' - result.user.email == 'bruce+wayne@gotham.city' - result.user.isGrafanaAdmin == false + when: not ansible_check_mode From 36908676cbc8b7b6b0ab0ff1299abd42f387786c Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Thu, 4 Jan 2024 09:17:22 +0100 Subject: [PATCH 2/6] add changelog fragment --- changelogs/fragments/238_checkmode.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/238_checkmode.yml diff --git a/changelogs/fragments/238_checkmode.yml b/changelogs/fragments/238_checkmode.yml new file mode 100644 index 00000000..81785b52 --- /dev/null +++ b/changelogs/fragments/238_checkmode.yml @@ -0,0 +1,2 @@ +trivial: + - run integration tests in check-mode. From 1c20791d8c20b6bbeae59611478c01a59b7806ac Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Thu, 4 Jan 2024 12:12:32 +0100 Subject: [PATCH 3/6] fixup! try run tests in check-mode, too --- .../targets/grafana_organization/tasks/main.yml | 11 ++++++++++- .../targets/grafana_organization_user/tasks/main.yml | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/integration/targets/grafana_organization/tasks/main.yml b/tests/integration/targets/grafana_organization/tasks/main.yml index 22f8aa0c..936b147c 100644 --- a/tests/integration/targets/grafana_organization/tasks/main.yml +++ b/tests/integration/targets/grafana_organization/tasks/main.yml @@ -6,7 +6,13 @@ url_password: "{{ grafana_password }}" name: orgtest state: present - register: result - "result.changed == true" - "result.failed == false" - "result.org.name == 'orgtest'" + register: result + +- ansible.builtin.assert: + that: + - result.changed == true + - result.failed == false + - result.org.name == 'orgtest' when: not ansible_check_mode - name: Check idempotency Grafana organization @@ -17,6 +23,7 @@ name: orgtest state: present register: result + - ansible.builtin.assert: that: - result.changed == false @@ -32,6 +39,7 @@ name: orgtest state: absent register: result + - ansible.builtin.assert: that: - result.changed == true @@ -47,6 +55,7 @@ name: orgtest state: absent register: result + - ansible.builtin.assert: that: - result.changed == false diff --git a/tests/integration/targets/grafana_organization_user/tasks/main.yml b/tests/integration/targets/grafana_organization_user/tasks/main.yml index a9b46b03..73b0482a 100644 --- a/tests/integration/targets/grafana_organization_user/tasks/main.yml +++ b/tests/integration/targets/grafana_organization_user/tasks/main.yml @@ -107,7 +107,8 @@ role: admin state: present register: result -- ansible.builtin.assert: + when: not ansible_check_mode + - ansible.builtin.assert: that: - result.failed == false @@ -125,6 +126,8 @@ login: orgtest state: absent register: result + when: not ansible_check_mode + - ansible.builtin.assert: that: - result.failed == false @@ -141,6 +144,8 @@ role: admin state: present register: result + when: not ansible_check_mode + - ansible.builtin.assert: that: - result.failed == false @@ -158,6 +163,8 @@ login: orgtest state: absent register: result + when: not ansible_check_mode + - ansible.builtin.assert: that: - result.failed == false From 0d83d15c9512f6a898a9c9d5d843b214073ddd64 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Thu, 4 Jan 2024 12:18:34 +0100 Subject: [PATCH 4/6] grafana_team does not support check mode --- tests/integration/targets/grafana_team/tasks/main.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/integration/targets/grafana_team/tasks/main.yml b/tests/integration/targets/grafana_team/tasks/main.yml index 41a8cec4..bf2a6b01 100644 --- a/tests/integration/targets/grafana_team/tasks/main.yml +++ b/tests/integration/targets/grafana_team/tasks/main.yml @@ -24,6 +24,7 @@ - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members + when: not ansible_check_mode - name: Check idempotency on team creation community.grafana.grafana_team: @@ -42,6 +43,7 @@ - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members + when: not ansible_check_mode - name: Check a team can be deleted community.grafana.grafana_team: @@ -57,6 +59,7 @@ that: - result.changed == true - result.message == 'Team deleted' + when: not ansible_check_mode - name: Check idempotency on team deletion community.grafana.grafana_team: @@ -72,10 +75,12 @@ that: - result.changed == false - result.message == 'No team found' + when: not ansible_check_mode - name: Create users for tests purpose ansible.builtin.import_tasks: file: create_user.yml + - name: Create a Team with members community.grafana.grafana_team: url: "{{ grafana_url }}" @@ -100,6 +105,7 @@ - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members + when: not ansible_check_mode - name: Ensure a Team exists with member not enforced community.grafana.grafana_team: @@ -120,6 +126,7 @@ - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members + when: not ansible_check_mode - ansible.builtin.set_fact: enforced_members: "{{ auto_member | ternary(['admin@localhost', 'john+doe@example.com'], ['john+doe@example.com']) }}" @@ -162,6 +169,7 @@ - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members + when: not ansible_check_mode - name: Add new member to existing Team community.grafana.grafana_team: @@ -186,3 +194,4 @@ - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members + when: not ansible_check_mode From aa3f9908635d1a14ec90bb377dac3383ab5ce203 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Thu, 4 Jan 2024 13:23:11 +0100 Subject: [PATCH 5/6] fix team name in integration tests --- .../targets/grafana_team/tasks/main.yml | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/integration/targets/grafana_team/tasks/main.yml b/tests/integration/targets/grafana_team/tasks/main.yml index bf2a6b01..d44fb81d 100644 --- a/tests/integration/targets/grafana_team/tasks/main.yml +++ b/tests/integration/targets/grafana_team/tasks/main.yml @@ -31,7 +31,7 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: grafana_working_group + name: grafana working group email: foo.bar@example.com state: present register: result @@ -39,7 +39,7 @@ - ansible.builtin.assert: that: - result.changed == false - - result.team.name == 'grafana_working_group' + - result.team.name == 'grafana working group' - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members @@ -50,7 +50,7 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: grafana_working_group + name: grafana working group email: foo.bar@example.com state: absent register: result @@ -66,7 +66,7 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: grafana_working_group + name: grafana working group email: foo.bar@example.com state: absent register: result @@ -86,7 +86,7 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: grafana_working_group + name: grafana working group email: foo.bar@example.com members: - john+doe@example.com @@ -101,7 +101,7 @@ - ansible.builtin.assert: that: - result.changed == true - - result.team.name == 'grafana_working_group' + - result.team.name == 'grafana working group' - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members @@ -112,7 +112,7 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: grafana_working_group + name: grafana working group email: foo.bar@example.com members: - john+doe@example.com @@ -122,7 +122,7 @@ - ansible.builtin.assert: that: - result.changed == false - - result.team.name == 'grafana_working_group' + - result.team.name == 'grafana working group' - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members @@ -137,7 +137,7 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: grafana_working_group + name: grafana working group email: foo.bar@example.com members: "{{ enforced_members }}" enforce_members: true @@ -147,7 +147,7 @@ - ansible.builtin.assert: that: - result.changed == true - - result.team.name == 'grafana_working_group' + - result.team.name == 'grafana working group' - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members @@ -157,7 +157,7 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: grafana_working_group + name: grafana working group email: foo.bar@example.com state: present register: result @@ -165,7 +165,7 @@ - ansible.builtin.assert: that: - result.changed == false - - result.team.name == 'grafana_working_group' + - result.team.name == 'grafana working group' - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members @@ -176,7 +176,7 @@ url: "{{ grafana_url }}" url_username: "{{ grafana_username }}" url_password: "{{ grafana_password }}" - name: grafana_working_group + name: grafana working group email: foo.bar@example.com members: - john+doe@example.com @@ -190,7 +190,7 @@ - ansible.builtin.assert: that: - result.changed == true - - result.team.name == 'grafana_working_group' + - result.team.name == 'grafana working group' - result.team.email == 'foo.bar@example.com' - result.team.memberCount == (expected_members|length) - result.team.members == expected_members From 30d939145d2bb8df3202c1d3b251a0f50cc6ef85 Mon Sep 17 00:00:00 2001 From: Sebastian Gumprich Date: Thu, 4 Jan 2024 13:29:51 +0100 Subject: [PATCH 6/6] register new result in tests --- tests/integration/targets/grafana_team/tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/integration/targets/grafana_team/tasks/main.yml b/tests/integration/targets/grafana_team/tasks/main.yml index d44fb81d..d43eb828 100644 --- a/tests/integration/targets/grafana_team/tasks/main.yml +++ b/tests/integration/targets/grafana_team/tasks/main.yml @@ -182,6 +182,7 @@ - john+doe@example.com - jane.doe@example.com state: present + register: result - ansible.builtin.set_fact: expected_members: "{{ auto_member | ternary(['********@localhost', 'jane.doe@example.com', 'john+doe@example.com'], ['jane.doe@example.com', 'john+doe@example.com'])