commands: Fix server panic regression

And now with a proper server test.

Fixes #9518
Fixes #9530
Fixes #9539
This commit is contained in:
Bjørn Erik Pedersen 2022-02-21 19:12:04 +01:00
parent 4ada09415d
commit aebde49b88
4 changed files with 45 additions and 15 deletions

View file

@ -329,7 +329,7 @@ type testSiteConfig struct {
contentDir string
}
func createSimpleTestSite(t *testing.T, cfg testSiteConfig) (string, func(), error) {
func createSimpleTestSite(t testing.TB, cfg testSiteConfig) (string, func(), error) {
d, clean, e := htesting.CreateTempDir(hugofs.Os, "hugo-cli")
if e != nil {
return "", nil, e
@ -392,12 +392,12 @@ Environment: {{ hugo.Environment }}
return d, clean, nil
}
func writeFile(t *testing.T, filename, content string) {
func writeFile(t testing.TB, filename, content string) {
must(t, os.MkdirAll(filepath.Dir(filename), os.FileMode(0755)))
must(t, ioutil.WriteFile(filename, []byte(content), os.FileMode(0755)))
}
func must(t *testing.T, err error) {
func must(t testing.TB, err error) {
if err != nil {
t.Fatal(err)
}