---
- debug:
    msg: "START eos_l2_interface/eapi/no_interface.yaml on connection={{ ansible_connection }}"

- name: Create fake interface
  eos_interface:
    name: Management0
  become: yes

- block:
  - name: eos_l2_interface shouldn't fail
    eos_l2_interface: &no_switchport
      name: Ethernet1
      state: absent
    become: yes
    register: result

  - assert:
      that: "'Interface does not exist' in result.warnings[0]"

  always:
  - name: Cleanup fake interface
    eos_config:
      lines:
        - no interface Management0
    become: yes

- name: eos_l2_interface should still not fail
  eos_l2_interface: *no_switchport
  become: yes
  register: result

- assert:
    that: "result.warnings is not defined"

- debug:
    msg: "END eos_l2_interface/eapi/no_interface.yaml on connection={{ ansible_connection }}"
