saltstack-formulas / openssh-formula

http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Other
90 stars 297 forks source link

test(inspec): display proper diff when `_mapdata` mismatch #192

Closed baby-gnu closed 4 years ago

baby-gnu commented 4 years ago

PR progress checklist (to be filled in by reviewers)


What type of PR is this?

Primary type

Secondary type

Does this PR introduce a BREAKING CHANGE?

No.

Related issues and/or pull requests

187

Describe the changes you're proposing

The use of eq instead of include premits to have a nice diff after the expected/got oneliners.

Pillar / config required to test the proposed changes

N/A

Debug log showing how the proposed changes work

Here is the output I get when modifying a _mapdata reference file:

  ×  `map.jinja` YAML dump: should contain the lines (1 failed)
     ✔  File /tmp/salt_mapdata_dump.yaml is expected to exist
     ×  File /tmp/salt_mapdata_dump.yaml content is expected to eq "# yamllint disable rule:indentation rule:line-length\n# Debian-10\n---\nmap_jinja:\n  config_get_roo...td: 'no'\n  Subsystem: sftp /usr/lib/openssh/sftp-server\n  UsePAM: 'yes'\n  X11Forwarding: 'yes'\n"

     expected: "# yamllint disable rule:indentation rule:line-length\n# Debian-10\n---\nmap_jinja:\n  config_get_roo...td: 'no'\n  Subsystem: sftp /usr/lib/openssh/sftp-server\n  UsePAM: 'yes'\n  X11Forwarding: 'yes'\n"
          got: "# yamllint disable rule:indentation rule:line-length\n# Debian-10\n---\nmap_jinja:\n  config_get_roo...td: 'no'\n  Subsystem: sftp /usr/lib/openssh/sftp-server\n  UsePAM: 'yes'\n  X11Forwarding: 'yes'\n"

     (compared using ==)

     Diff:

     @@ -10,11 +10,12 @@
        absent_dsa_keys: false
        absent_ecdsa_keys: false
        absent_ed25519_keys: false
     -  absent_rsa_keys: true
     +  absent_rsa_keys: false
        auth:
          joe-non-valid-ssh-key:
          - comment: obsolete key - removed
            enc: ssh-rsa
     +      present: false
            source: salt://ssh_keys/joe.no-valid.pub
            user: joe
          joe-valid-ssh-key-desktop:
     @@ -22,6 +23,12 @@
            enc: ssh-rsa
            present: true
            source: salt://ssh_keys/joe.desktop.pub
     +      user: joe
     +    joe-valid-ssh-key-notebook:
     +    - comment: main key - notebook
     +      enc: ssh-rsa
     +      present: true
     +      source: salt://ssh_keys/joe.netbook.pub
            user: joe
        auth_map:
          personal_keys:

Documentation checklist

Testing checklist

Additional context

pull-assistant[bot] commented 4 years ago
Score: 1.00

Best reviewed: commit by commit


Optimal code review plan

     test(inspec): display proper diff when `_mapdata` mismatch

Powered by Pull Assistant. Last update 1c99556 ... 1c99556. Read the comment docs.

myii commented 4 years ago

Excellent find, @baby-gnu!

saltstack-formulas-travis commented 4 years ago

:tada: This PR is included in version 2.0.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: