From 2f0a45bb5a613b8a85e8e5615cfed464f1eadbd9 Mon Sep 17 00:00:00 2001 From: William Melody Date: Tue, 26 Jan 2016 18:31:17 -0800 Subject: [PATCH] Add disabled.bats. --- test/disabled.bats | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 test/disabled.bats diff --git a/test/disabled.bats b/test/disabled.bats new file mode 100644 index 0000000..3d980e1 --- /dev/null +++ b/test/disabled.bats @@ -0,0 +1,35 @@ +#!/usr/bin/env bats + +load test_helper + +# `hosts disabled` ############################################################# + +@test "\`disabled\` with no arguments exits with status 0." { + { + run "$_HOSTS" add 0.0.0.0 example.com + run "$_HOSTS" add 0.0.0.0 example.net + run "$_HOSTS" add 127.0.0.1 example.com + run "$_HOSTS" disable example.com + } + + run "$_HOSTS" disabled + printf "\$status: %s\n" "$status" + printf "\$output: '%s'\n" "$output" + [[ $status -eq 0 ]] +} + +@test "\`disabled\` with no arguments prints list of disabled records." { + { + run "$_HOSTS" add 0.0.0.0 example.com + run "$_HOSTS" add 0.0.0.0 example.net + run "$_HOSTS" add 127.0.0.1 example.com + run "$_HOSTS" disable example.com + } + + run "$_HOSTS" disabled + printf "\$status: %s\n" "$status" + printf "\$output: '%s'\n" "$output" + [[ "${lines[0]}" == "0.0.0.0 example.com" ]] + [[ "${lines[1]}" == "127.0.0.1 example.com" ]] + [[ "${lines[2]}" == "" ]] +}