mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-28 15:56:33 +00:00
Add initial test structure with test 'hosts' file.
This commit is contained in:
parent
eeab6e8ba1
commit
30ed049441
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
test/tmp/*
|
||||||
|
!test/tmp/.keep
|
10
test/fixtures/hosts
vendored
Normal file
10
test/fixtures/hosts
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
##
|
||||||
|
# Host Database
|
||||||
|
#
|
||||||
|
# localhost is used to configure the loopback interface
|
||||||
|
# when the system is booting. Do not change this entry.
|
||||||
|
##
|
||||||
|
127.0.0.1 localhost
|
||||||
|
255.255.255.255 broadcasthost
|
||||||
|
::1 localhost
|
||||||
|
fe80::1%lo0 localhost
|
17
test/hosts.bats
Normal file
17
test/hosts.bats
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load test_helper
|
||||||
|
|
||||||
|
@test "when passed no arguments exit with status 0" {
|
||||||
|
run "$_HOSTS"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "when passed no arguments print enabled rules." {
|
||||||
|
run "$_HOSTS"
|
||||||
|
[[ "${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]}" == "" ]]
|
||||||
|
}
|
13
test/test_helper.bash
Normal file
13
test/test_helper.bash
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
setup() {
|
||||||
|
# `$_HOSTS`
|
||||||
|
#
|
||||||
|
# The location of the `hosts` script being tested.
|
||||||
|
export _HOSTS="${BATS_TEST_DIRNAME}/../hosts"
|
||||||
|
|
||||||
|
export HOSTS_PATH="${BATS_TEST_DIRNAME}/tmp/hosts"
|
||||||
|
cp "${BATS_TEST_DIRNAME}/fixtures/hosts" "${BATS_TEST_DIRNAME}/tmp/hosts"
|
||||||
|
}
|
||||||
|
|
||||||
|
teardown() {
|
||||||
|
rm "${BATS_TEST_DIRNAME}/tmp/hosts"
|
||||||
|
}
|
0
test/tmp/.keep
Normal file
0
test/tmp/.keep
Normal file
Loading…
Reference in New Issue
Block a user