---
- debug:
    msg: "START exos_lldp_global merged integration tests on connection={{ ansible_connection }}"

- include_tasks: _reset_config.yaml

- block:
  - name: Merge the provided configuration with the exisiting running configuration
    exos_lldp_global: &merged
      config:
        interval: 10
        tlv_select:
          system_description: false
          system_capabilities: false
      state: merged
    register: result

  - name: Assert that before dicts were correctly generated
    assert:
      that: "{{ merged['before'] == result['before'] }}"

  - name: Assert that correct set of requests were generated
    assert:
      that:
        - "{{ merged['requests'][0]['method'] == result['requests'][0]['method'] }}"
        - "{{ merged['requests'][0]['path'] == result['requests'][0]['path'] }}"
        - "{{ merged['requests'][0]['data'] == result['requests'][0]['data'] }}"

  - name: Assert that after dicts was correctly generated
    assert:
      that:
        - "{{ merged['after'] == result['after'] }}"

  - name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
    exos_lldp_global: *merged
    register: result

  - name: Assert that the previous task was idempotent
    assert:
      that:
        - " result['changed'] == false"

  - name: Assert that before dicts were correctly generated
    assert:
      that:
        - "{{ merged['after'] == result['before'] }}"

  always:
  - include_tasks: _reset_config.yaml
