From a55838b0133010791f3ce28010bdec88fbf8099d Mon Sep 17 00:00:00 2001 From: Kevin Breit Date: Fri, 1 Feb 2019 20:19:25 -0800 Subject: [PATCH] Digital Ocean integration test for digital_ocean_tag (#49169) * Add Digital Ocean integration test template - Actual integration tests will come shortly * Add digital_ocean-tag test * Add integration test for creating and deleting tags * Remove cloud confiugration file * Enhancements for integration test for idempotency - Added new lines per review - Added proper tests for idempotency checks - Actual module is broken so deletion test doesn't work * Add check for do_api_key and instruct if it doesn't work. * Fix indentation * Remove idempotency test for nonidempotency action * Add notes for delete idempotency --- .../targets/digital_ocean_tag/aliases | 2 + .../targets/digital_ocean_tag/tasks/main.yml | 51 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/integration/targets/digital_ocean_tag/aliases create mode 100644 test/integration/targets/digital_ocean_tag/tasks/main.yml diff --git a/test/integration/targets/digital_ocean_tag/aliases b/test/integration/targets/digital_ocean_tag/aliases new file mode 100644 index 0000000000..6320774d67 --- /dev/null +++ b/test/integration/targets/digital_ocean_tag/aliases @@ -0,0 +1,2 @@ +digital_ocean +unsupported diff --git a/test/integration/targets/digital_ocean_tag/tasks/main.yml b/test/integration/targets/digital_ocean_tag/tasks/main.yml new file mode 100644 index 0000000000..aea355facc --- /dev/null +++ b/test/integration/targets/digital_ocean_tag/tasks/main.yml @@ -0,0 +1,51 @@ +--- +- block: + - name: Test API key is provided. + fail: + msg: do_api_key should be defined in integration_config.yml + when: do_api_key is not defined + + - name: Create a new tag + digital_ocean_tag: + oauth_token: '{{do_api_key}}' + name: integration-test + state: present + register: create_tag + + - name: Create a new tag for idempotency + digital_ocean_tag: + oauth_token: '{{do_api_key}}' + name: integration-test + state: present + register: create_tag_idempotent + + - debug: + var: create_tag + + - assert: + that: + - create_tag.changed == True + - create_tag_idempotent.changed == False + - create_tag.data.tag.name == "integration-test" + + always: + - name: Delete tag + digital_ocean_tag: + oauth_token: '{{do_api_key}}' + name: integration-test + state: absent + register: delete_tag + +# FIXME: Deleting a tag isn't idempotent +# - name: Delete tag with idempotency +# digital_ocean_tag: +# oauth_token: '{{do_api_key}}' +# name: integration-test +# state: absent +# register: delete_tag_idempotent + + - assert: + that: + - delete_tag.changed == True +# FIXME: Deleting a tag isn't idempotent +# - delete_tag_idempotent.changed == False