From 4cb653919700f9aaf7eb0eacd3144d6e54cce438 Mon Sep 17 00:00:00 2001 From: Roman Inflianskas Date: Wed, 11 Jun 2014 23:08:51 +0400 Subject: [PATCH] [dpaste] Add tests --- plugins/dpaste/tests/helper.fish | 7 +++++++ plugins/dpaste/tests/test_dpaste.fish | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 plugins/dpaste/tests/helper.fish create mode 100755 plugins/dpaste/tests/test_dpaste.fish diff --git a/plugins/dpaste/tests/helper.fish b/plugins/dpaste/tests/helper.fish new file mode 100644 index 0000000..0ac6202 --- /dev/null +++ b/plugins/dpaste/tests/helper.fish @@ -0,0 +1,7 @@ +set -l fish_tank /usr/local/share/fish-tank/tank.fish +if not test -e $fish_tank + echo 'error: fish-tank is required to run these tests (https://github.com/terlar/fish-tank)' + exit 1 +end + +source $fish_tank diff --git a/plugins/dpaste/tests/test_dpaste.fish b/plugins/dpaste/tests/test_dpaste.fish new file mode 100755 index 0000000..163302c --- /dev/null +++ b/plugins/dpaste/tests/test_dpaste.fish @@ -0,0 +1,23 @@ +#!/usr/bin/env fish + +function suite_dpaste + function setup + set -g __dpaste_expires_choises + source ../dpaste.fish + __dpaste_set_defaults + end + + function test_dpaste_parse_expires + assert_equal text (__dpaste_parse_expires text) + assert_equal "https://dpaste.de/api/?format=url" $__dpaste_send_url + assert_equal text (__dpaste_parse_expires -t never text) + assert_equal "https://dpaste.de/api/?format=url&expires=never" $__dpaste_send_url + assert_equal text (__dpaste_parse_expires -t hour 3600) + assert_equal "https://dpaste.de/api/?format=url&expires=" $__dpaste_send_url + end +end + +if not set -q tank_running + source (dirname (status -f))/helper.fish + tank_run +end