From ae9c4f0f4ba52376cc4bbdc7f3407556c403f625 Mon Sep 17 00:00:00 2001 From: William Melody Date: Sun, 24 Jan 2016 21:21:40 -0800 Subject: [PATCH] Add tests for `file`. --- test/file.bats | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/file.bats diff --git a/test/file.bats b/test/file.bats new file mode 100644 index 0000000..0455550 --- /dev/null +++ b/test/file.bats @@ -0,0 +1,23 @@ +#!/usr/bin/env bats + +load test_helper + +@test "\`file\` exits with status 0." { + run "$_HOSTS" file + [ "$status" -eq 0 ] +} + +@test "\`file\` prints file contents." { + run "$_HOSTS" file + [[ "${lines[0]}" == "##" ]] + [[ "${lines[1]}" == "# Host Database" ]] + [[ "${lines[2]}" == "#" ]] + [[ "${lines[3]}" == "# localhost is used to configure the loopback interface" ]] + [[ "${lines[4]}" == "# when the system is booting. Do not change this entry." ]] + [[ "${lines[5]}" == "##" ]] + [[ "${lines[6]}" == "127.0.0.1 localhost" ]] + [[ "${lines[7]}" == "255.255.255.255 broadcasthost" ]] + [[ "${lines[8]}" == "::1 localhost" ]] + [[ "${lines[9]}" == "fe80::1%lo0 localhost" ]] + [[ "${lines[10]}" == "" ]] +}