From 5847cec5985fb95c337e76fd2348a4311af67c0d Mon Sep 17 00:00:00 2001 From: William Melody Date: Tue, 26 Jan 2016 18:53:41 -0800 Subject: [PATCH] Add enabled.bats. --- test/enabled.bats | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/enabled.bats diff --git a/test/enabled.bats b/test/enabled.bats new file mode 100644 index 0000000..8c5e61e --- /dev/null +++ b/test/enabled.bats @@ -0,0 +1,37 @@ +#!/usr/bin/env bats + +load test_helper + +# `hosts enabled` ############################################################# + +@test "\`enabled\` 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.2 example.com + run "$_HOSTS" disable 0.0.0.0 + } + + run "$_HOSTS" enabled + printf "\$status: %s\n" "$status" + printf "\$output: '%s'\n" "$output" + [[ $status -eq 0 ]] +} + +@test "\`enabled\` with no arguments prints list of enabled 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.2 example.com + run "$_HOSTS" disable 0.0.0.0 + } + + run "$_HOSTS" enabled + printf "\$status: %s\n" "$status" + printf "\$output: '%s'\n" "$output" + [[ "${lines[0]}" == "127.0.0.1 localhost" ]] + [[ "${lines[1]}" == "255.255.255.255 broadcasthost" ]] + [[ "${lines[2]}" == "::1 localhost" ]] + [[ "${lines[3]}" == "fe80::1%lo0 localhost" ]] + [[ "${lines[4]}" == "127.0.0.2 example.com" ]] +}