mirror of
https://github.com/gohugoio/hugo.git
synced 2025-02-18 14:11:29 +00:00
Fix some of the "new site" tests
This commit is contained in:
parent
b81fc1be4e
commit
e29ede7055
2 changed files with 16 additions and 6 deletions
|
@ -15,12 +15,12 @@ package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"errors"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/hugo/create"
|
"github.com/spf13/hugo/create"
|
||||||
"github.com/spf13/hugo/helpers"
|
"github.com/spf13/hugo/helpers"
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/spf13/afero"
|
|
||||||
"github.com/spf13/hugo/hugofs"
|
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/spf13/afero"
|
||||||
|
"github.com/spf13/hugo/hugofs"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Issue #1133
|
// Issue #1133
|
||||||
|
@ -41,10 +42,20 @@ func TestDoNewSite(t *testing.T) {
|
||||||
checkNewSiteInited(basepath, t)
|
checkNewSiteInited(basepath, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDoNewSite_noerror_base_exists_but_empty(t *testing.T) {
|
||||||
|
basepath := filepath.Join(os.TempDir(), "blog")
|
||||||
|
hugofs.SourceFs = new(afero.MemMapFs)
|
||||||
|
hugofs.SourceFs.MkdirAll(basepath, 777)
|
||||||
|
err := doNewSite(basepath, false)
|
||||||
|
assert.Nil(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDoNewSite_error_base_exists(t *testing.T) {
|
func TestDoNewSite_error_base_exists(t *testing.T) {
|
||||||
basepath := filepath.Join(os.TempDir(), "blog")
|
basepath := filepath.Join(os.TempDir(), "blog")
|
||||||
hugofs.SourceFs = new(afero.MemMapFs)
|
hugofs.SourceFs = new(afero.MemMapFs)
|
||||||
hugofs.SourceFs.MkdirAll(basepath, 777)
|
hugofs.SourceFs.MkdirAll(basepath, 777)
|
||||||
|
hugofs.SourceFs.Create(filepath.Join(basepath, "foo"))
|
||||||
|
// Since the directory already exists and isn't empty, expect an error
|
||||||
err := doNewSite(basepath, false)
|
err := doNewSite(basepath, false)
|
||||||
assert.NotNil(t, err)
|
assert.NotNil(t, err)
|
||||||
}
|
}
|
||||||
|
@ -59,8 +70,7 @@ func TestDoNewSite_force_empty_dir(t *testing.T) {
|
||||||
checkNewSiteInited(basepath, t)
|
checkNewSiteInited(basepath, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(spf13): Fix and re-enable this.
|
func TestDoNewSite_error_force_dir_inside_exists(t *testing.T) {
|
||||||
func _TestDoNewSite_error_force_dir_inside_exists(t *testing.T) {
|
|
||||||
basepath := filepath.Join(os.TempDir(), "blog")
|
basepath := filepath.Join(os.TempDir(), "blog")
|
||||||
contentPath := filepath.Join(basepath, "content")
|
contentPath := filepath.Join(basepath, "content")
|
||||||
hugofs.SourceFs = new(afero.MemMapFs)
|
hugofs.SourceFs = new(afero.MemMapFs)
|
||||||
|
|
Loading…
Reference in a new issue