---
  - debug:
      msg: "Start nxos_lldp_global replaced integration tests connection = {{ansible_connection}}"

  - name: Enable lldp feature
    nxos_feature:
      feature: lldp
      state: enabled

  - block:
    - name: Setup
      cli_config:
        config: |
          lldp holdtime 125
          lldp portid-subtype 1
          lldp tlv-select system-name 
          no lldp tlv-select port-vlan 
          no lldp tlv-select power-management

    - name: Replaced
      nxos_lldp_global: &replaced
        config:
          holdtime: 125
          timer: 35
          tlv_select:
            system: 
               name: false
               description: false
            port:
              vlan: false
            dcbxp: false
        state: replaced
      register: result

    - assert:
        that:
          - "result.changed == true"
          - "'lldp timer 35' in result.commands"
          - "'lldp tlv-select power-management' in result.commands"
          - "'no lldp portid-subtype 1' in result.commands"
          - "'no lldp tlv-select system-name' in result.commands"
          - "'no lldp tlv-select system-description' in result.commands"
          - "'no lldp tlv-select dcbxp' in result.commands"
          - "result.commands|length == 6"

    - name: Gather lldp_global post facts
      nxos_facts: 
        gather_subset:
          - '!all'
          - '!min'
        gather_network_resources: lldp_global

    - assert: 
        that:
          - "ansible_facts.network_resources.lldp_global == result.after"

    - name: Idempotence - Replaced
      nxos_lldp_global: *replaced
      register: result
 
    - assert:
        that:
          - "result.changed == false"
          - "result.commands|length == 0"

    always:
    - name: teardown
      nxos_feature:
        feature: lldp
        state: disabled
