Skip to content

Commit

Permalink
Ignore SCP return in tests
Browse files Browse the repository at this point in the history
SCP can sometimes return 1 even when it succeeds, so we'll just ignore the return and check the file
exists and has the contents expected instead
  • Loading branch information
jjcarstens committed Sep 11, 2022
1 parent 3a1f6c6 commit dad7aee
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/nerves_ssh_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ defmodule NervesSSHTest do

File.write!(download_path, "asdf")

{_output, 0} =
# SCP can sometimes return 1 even when it succeeds,
# so we'll just ignore the return here and rely on the file
# check below
_ =
System.cmd("scp", [
"-o",
"UserKnownHostsFile /dev/null",
Expand All @@ -158,6 +161,7 @@ defmodule NervesSSHTest do
"#{filename}"
])

assert File.exists?(filename)
assert File.read!(filename) == "asdf"
end

Expand All @@ -175,7 +179,10 @@ defmodule NervesSSHTest do

File.write!(filename, "asdf")

{_output, 0} =
# SCP can sometimes return 1 even when it succeeds,
# so we'll just ignore the return here and rely on the file
# check below
_ =
System.cmd("scp", [
"-o",
"UserKnownHostsFile /dev/null",
Expand All @@ -189,6 +196,7 @@ defmodule NervesSSHTest do
"test_user@localhost:#{upload_path}"
])

assert File.exists?(upload_path)
assert File.read!(upload_path) == "asdf"
end

Expand Down

0 comments on commit dad7aee

Please sign in to comment.