mirror of https://github.com/cbednarski/hostess
Add test hosts file and basic test for Ls command; fix ls panic
parent
5950705e9d
commit
35413097c7
@ -0,0 +1,23 @@
|
|||||||
|
package hostess
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/codegangsta/cli"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestStrPadRight(t *testing.T) {
|
||||||
|
assert.Equal(t, "", StrPadRight("", 0), "Zero-length no padding")
|
||||||
|
assert.Equal(t, " ", StrPadRight("", 10), "Zero-length 10 padding")
|
||||||
|
assert.Equal(t, "string", StrPadRight("string", 0), "6-length 0 padding")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestLs(t *testing.T) {
|
||||||
|
os.Setenv("HOSTESS_PATH", "test-fixtures/hostfile1")
|
||||||
|
defer os.Setenv("HOSTESS_PATH", "")
|
||||||
|
c := cli.NewContext(cli.NewApp(), &flag.FlagSet{}, nil)
|
||||||
|
Ls(c)
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
#192.168.0.1 pie.dev.example.com
|
||||||
|
192.168.0.2 cookie.example.com
|
||||||
|
::1 hostname.pie hostname.candy cake.example.com
|
||||||
|
fe:23b3:890e:342e::ef strawberry.pie.example.com
|
||||||
|
# fe:23b3:890e:342e::ef dev.strawberry.pie.example.com
|
||||||
|
192.168.1.3 pie.example.com
|
||||||
|
127.0.1.1 robobrain
|
||||||
|
# fe:23b3:890e:342e::ef chocolate.cake.example.com chocolate.ru.example.com chocolate.tr.example.com chocolate.cookie.example.com
|
||||||
|
fe:23b3:890e:342e::ef chocolate.pie.example.com
|
||||||
|
::1 localhost
|
||||||
|
127.0.0.1 localhost
|
||||||
|
192.168.1.1 pie.example.com
|
||||||
|
192.168.1.1 strawberry.pie.example.com
|
Loading…
Reference in New Issue