You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hostess/commands_test.go

40 lines
865 B
Go

package main
import (
"os"
"path/filepath"
"testing"
)
func TestStrPadRight(t *testing.T) {
type testCase struct {
Expected string
Output string
Name string
}
cases := []testCase{
{"", StrPadRight("", 0), "Zero-length no padding"},
{" ", StrPadRight("", 10), "Zero-length 10 padding"},
{"string", StrPadRight("string", 0), "6-length 0 padding"},
}
for _, test := range cases {
if test.Output != test.Expected {
t.Errorf("Failed case: %s\nExpected %q Found %q", test.Name, test.Expected, test.Output)
}
}
}
func TestLoadHostfile(t *testing.T) {
// Issue #39: This hosts file contains a duplicate. We should paper over it.
os.Setenv("HOSTESS_PATH", filepath.Join("testdata", "issue39"))
defer os.Unsetenv("HOSTESS_PATH")
options := &Options{}
if _, err := LoadHostfile(options); err != nil {
t.Fatal(err)
}
}