croc: add passthru.tests

This commit is contained in:
Markus S. Wamser 2020-10-20 09:06:43 +02:00 committed by Frederik Rietdijk
parent 50277ebdd2
commit 166a0642d4
2 changed files with 26 additions and 1 deletions

View file

@ -1,4 +1,4 @@
{ stdenv, buildGoModule, fetchFromGitHub }:
{ stdenv, buildGoModule, fetchFromGitHub, callPackage}:
buildGoModule rec {
pname = "croc";
@ -17,6 +17,11 @@ buildGoModule rec {
subPackages = [ "." ];
passthru = {
tests = {
local-relay = callPackage ./test-local-relay.nix {};
};
};
meta = with stdenv.lib; {
description =
"Easily and securely send things from one computer to another";

View file

@ -0,0 +1,20 @@
{ stdenv, croc }:
stdenv.mkDerivation {
name = "croc-test-local-relay";
meta.timeout = 300;
buildCommand = ''
HOME=$(mktemp -d)
# start a local relay
${croc}/bin/croc relay --ports 11111,11112 &
# start sender in background
MSG="See you later, alligator!"
${croc}/bin/croc --relay localhost:11111 send --code correct-horse-battery-staple --text "$MSG" &
# wait for things to settle
sleep 1
# receive
MSG2=$(${croc}/bin/croc --relay localhost:11111 --yes correct-horse-battery-staple)
# compare
[ "$MSG" = "$MSG2" ] && touch $out
'';
}