Add file reporting to planner
This commit is contained in:
parent
13d2c55206
commit
c6ad532b94
2 changed files with 34 additions and 1 deletions
|
@ -2,8 +2,20 @@ package hugolib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Site) ShowPlan(out io.Writer) (err error) {
|
func (s *Site) ShowPlan(out io.Writer) (err error) {
|
||||||
|
if len(s.Files) <= 0 {
|
||||||
|
fmt.Fprintf(out, "No source files provided.\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, file := range s.Files {
|
||||||
|
fmt.Fprintf(out, "%s\n", file)
|
||||||
|
if s.Target == nil {
|
||||||
|
fmt.Fprintf(out, " *implicit* => %s\n", "!no target specified!")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,35 @@
|
||||||
package hugolib
|
package hugolib
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
"bytes"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
expected := "No source files provided.\n"
|
||||||
|
got := out.String()
|
||||||
|
checkShowPlanExpected(t, expected, got)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDegenerateNoTarget(t *testing.T) {
|
func TestDegenerateNoTarget(t *testing.T) {
|
||||||
s := new(Site)
|
s := new(Site)
|
||||||
|
s.Files = append(s.Files, "foo/bar/file.md")
|
||||||
out := new(bytes.Buffer)
|
out := new(bytes.Buffer)
|
||||||
if err := s.ShowPlan(out); err != nil {
|
if err := s.ShowPlan(out); err != nil {
|
||||||
t.Errorf("ShowPlan unexpectedly returned an error: %s", err)
|
t.Errorf("ShowPlan unexpectedly returned an error: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expected := "foo/bar/file.md\n *implicit* => !no target specified!\n"
|
||||||
|
checkShowPlanExpected(t, expected, out.String())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue