jorgebucaran / fishtape

100% pure-Fish test runner
MIT License
347 stars 20 forks source link

How to test ssh-add? #22

Closed edouard-lopez closed 6 years ago

edouard-lopez commented 8 years ago

I'm having trouble testing a ssh-add command for the herrbischoff/fish-ssh-agent project. So far I've tested almost everything but I feel there is some fish-related catch I'm not aware of.

Source

…
ssh-add $private >/tmp/ssh-add.log ^ /tmp/ssh-add.err
…

Error: what I got

$ fishtape test/*.fish | tap-min
Could not open a connection to your authentication agent.
Could not open a connection to your authentication agent.

    10 tests complete (9ms)
    null Add given keys
    ---
    operator: =
    expected: '0'
    received: '1'
    ...

Question

Am I in some special context where ssh-agent is unavailable ? Or is it something else?

jorgebucaran commented 8 years ago

This looks like a tough one.

Do you think you'd be able to help @Markcial?

Markcial commented 8 years ago

I'd recommend to skip the ssh-add part by using mock library, it's not necessary to test 3rd parties implementations (except you want to test the integration).

if you still want to test integration i pushed a branch to my repo, feel free to check it or ask for more information about the mock library usage :D

:beers:

jorgebucaran commented 8 years ago

Thanks @Markcial.

edouard-lopez commented 6 years ago

The merged PR does it like:

test "$TEST - Add a given key"
  (
      eval (ssh-agent -c) > /dev/null
      set old_keys_list (ssh-add -l | grep --count RSA)
      ssh-keygen -f $path/.test -N '' >/dev/null

      __add_keys $path/.test.pub

      set new_keys_list (ssh-add -l | grep --count RSA)
      math "$new_keys_list - $old_keys_list"
    ) = 1
end
jorgebucaran commented 6 years ago

@edouard-lopez Wny did you close here? Did you solve the issue?

edouard-lopez commented 6 years ago

@jorgebucaran Yes, the code above is running correctly