~anjan/sxmo-check

7af70f4b5c1873d364537cb9919bee603796ab9b — Anjandev Momi 2 years ago 3f6d480
sending test works
2 files changed, 20 insertions(+), 11 deletions(-)

M lib/text.sh
M spec/text_spec.sh
M lib/text.sh => lib/text.sh +2 -8
@@ 15,12 15,6 @@ sending() {

	SEND_ME="$1"
	sxmo_modemsendsms.sh "$CHEOGRAM_NUM" "$SEND_ME" > /dev/null
	# TODO: Why do I need to run the following command outside of shellspec?
	# outside of shellspec ./go-sendxmpp writes the text to file
	./go-sendxmpp -l > sendingdat &
	sleep 4s
	killall go-sendxmpp
	killall go-sendxmpp
	sleep 2s
	tail -n 1 sendingdat
	sleep 4s # wait for go-sendxmpp to receive the message
	tail -n 1 /tmp/recv
}

M spec/text_spec.sh => spec/text_spec.sh +18 -3
@@ 3,14 3,29 @@
%const NAME: value
% DATE: "$(date) $(cat /dev/urandom | base64 | head -n 1)"

Describe 'text.sh'
Describe "receiving"
  Include lib/text.sh
  It 'Can receive plaintext message pinephone'
  It 'Can receive plaintext message on pinephone'
    When call recieving "Receiving plain text at $DATE" ShellSpec
    The output should equal "Receiving plain text at $DATE"
  End
End
Describe "sending"
  Include lib/text.sh
  setup() {
	. ./.secrets
    ./go-sendxmpp -l > /tmp/recv &
    sleep 1
    pid=$!
  }
  BeforeRun setup
  cleanup() {
    kill -TERM "$pid"
    wait "$pid"
  }
  AfterRun cleanup
  It 'Can send plaintext message from pinephone'
    When call sending "Sending plain text at $DATE" ShellSpec
    When run sending "Sending plain text at $DATE" ShellSpec
    The output should equal "Sending plain text at $DATE"
  End
End