hugo/hugolib/site_show_plan_test.go

36 lines
866 B
Go
Raw Normal View History

2013-09-01 04:13:04 +00:00
package hugolib
import (
2013-09-01 14:43:29 +00:00
"bytes"
"testing"
2013-09-01 04:13:04 +00:00
)
2013-09-01 14:43:29 +00:00
func checkShowPlanExpected(t *testing.T, expected, got string) {
if got != expected {
t.Errorf("ShowPlan expected:\n%q\ngot\n%q", expected, got)
}
}
func TestDegenerateNoFiles(t *testing.T) {
s := new(Site)
out := new(bytes.Buffer)
if err := s.ShowPlan(out); err != nil {
t.Errorf("ShowPlan unexpectedly returned an error: %s", err)
2013-09-01 14:43:29 +00:00
}
expected := "No source files provided.\n"
got := out.String()
checkShowPlanExpected(t, expected, got)
}
2013-09-01 04:13:04 +00:00
func TestDegenerateNoTarget(t *testing.T) {
s := new(Site)
2013-09-01 14:43:29 +00:00
s.Files = append(s.Files, "foo/bar/file.md")
2013-09-01 04:13:04 +00:00
out := new(bytes.Buffer)
if err := s.ShowPlan(out); err != nil {
t.Errorf("ShowPlan unexpectedly returned an error: %s", err)
}
2013-09-01 14:43:29 +00:00
expected := "foo/bar/file.md\n *implicit* => !no target specified!\n"
checkShowPlanExpected(t, expected, out.String())
2013-09-01 04:13:04 +00:00
}