"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "modules/client_test.go" between
hugo-0.80.0.tar.gz and hugo-0.81.0.tar.gz

About: Hugo is a static site generator that takes a source directory of Markdown files and templates and uses these as input to create a complete website (written in Go).

client_test.go  (hugo-0.80.0):client_test.go  (hugo-0.81.0)
skipping to change at line 21 skipping to change at line 21
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
package modules package modules
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
"sync/atomic"
"testing" "testing"
"github.com/gohugoio/hugo/hugofs/glob" "github.com/gohugoio/hugo/hugofs/glob"
"github.com/gohugoio/hugo/htesting" "github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/hugofs"
qt "github.com/frankban/quicktest" qt "github.com/frankban/quicktest"
) )
func TestClient(t *testing.T) { func TestClient(t *testing.T) {
modName := "hugo-modules-basic-test" modName := "hugo-modules-basic-test"
modPath := "github.com/gohugoio/tests/" + modName modPath := "github.com/gohugoio/tests/" + modName
defaultImport := "modh2_2"
expect := `github.com/gohugoio/tests/hugo-modules-basic-test github.com/g ohugoio/hugoTestModules1_darwin/modh2_2@v1.4.0 expect := `github.com/gohugoio/tests/hugo-modules-basic-test github.com/g ohugoio/hugoTestModules1_darwin/modh2_2@v1.4.0
github.com/gohugoio/hugoTestModules1_darwin/modh2_2@v1.4.0 github.com/gohugoio/h ugoTestModules1_darwin/modh2_2_1v@v1.3.0 github.com/gohugoio/hugoTestModules1_darwin/modh2_2@v1.4.0 github.com/gohugoio/h ugoTestModules1_darwin/modh2_2_1v@v1.3.0
github.com/gohugoio/hugoTestModules1_darwin/modh2_2@v1.4.0 github.com/gohugoio/h ugoTestModules1_darwin/modh2_2_2@v1.3.0 github.com/gohugoio/hugoTestModules1_darwin/modh2_2@v1.4.0 github.com/gohugoio/h ugoTestModules1_darwin/modh2_2_2@v1.3.0
` `
c := qt.New(t) c := qt.New(t)
var clientID uint64 // we increment this to get each test in its own dire ctory.
newClient := func(c *qt.C, withConfig func(cfg *ClientConfig)) (*Client, newClient := func(c *qt.C, withConfig func(cfg *ClientConfig), imp string
func()) { ) (*Client, func()) {
workingDir, clean, err := htesting.CreateTempDir(hugofs.Os, modNa atomic.AddUint64(&clientID, uint64(1))
me) workingDir, clean, err := htesting.CreateTempDir(hugofs.Os, fmt.S
printf("%s-%d", modName, clientID))
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
themesDir := filepath.Join(workingDir, "themes") themesDir := filepath.Join(workingDir, "themes")
err = os.Mkdir(themesDir, 0777) err = os.Mkdir(themesDir, 0777)
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
ccfg := ClientConfig{ ccfg := ClientConfig{
Fs: hugofs.Os, Fs: hugofs.Os,
WorkingDir: workingDir, WorkingDir: workingDir,
ThemesDir: themesDir, ThemesDir: themesDir,
} }
withConfig(&ccfg) withConfig(&ccfg)
ccfg.ModuleConfig.Imports = []Import{{Path: "github.com/gohugoio/ hugoTestModules1_darwin/modh2_2"}} ccfg.ModuleConfig.Imports = []Import{{Path: "github.com/gohugoio/ hugoTestModules1_darwin/" + imp}}
client := NewClient(ccfg) client := NewClient(ccfg)
return client, clean return client, clean
} }
c.Run("All", func(c *qt.C) { c.Run("All", func(c *qt.C) {
client, clean := newClient(c, func(cfg *ClientConfig) { client, clean := newClient(c, func(cfg *ClientConfig) {
cfg.ModuleConfig = DefaultModuleConfig cfg.ModuleConfig = DefaultModuleConfig
}) }, defaultImport)
defer clean() defer clean()
// Test Init // Test Init
c.Assert(client.Init(modPath), qt.IsNil) c.Assert(client.Init(modPath), qt.IsNil)
// Test Collect // Test Collect
mc, err := client.Collect() mc, err := client.Collect()
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
c.Assert(len(mc.AllModules), qt.Equals, 4) c.Assert(len(mc.AllModules), qt.Equals, 4)
for _, m := range mc.AllModules { for _, m := range mc.AllModules {
skipping to change at line 106 skipping to change at line 110
// Test Tidy // Test Tidy
c.Assert(client.Tidy(), qt.IsNil) c.Assert(client.Tidy(), qt.IsNil)
}) })
c.Run("IgnoreVendor", func(c *qt.C) { c.Run("IgnoreVendor", func(c *qt.C) {
client, clean := newClient( client, clean := newClient(
c, func(cfg *ClientConfig) { c, func(cfg *ClientConfig) {
cfg.ModuleConfig = DefaultModuleConfig cfg.ModuleConfig = DefaultModuleConfig
cfg.IgnoreVendor = globAll cfg.IgnoreVendor = globAll
}) }, defaultImport)
defer clean() defer clean()
c.Assert(client.Init(modPath), qt.IsNil) c.Assert(client.Init(modPath), qt.IsNil)
_, err := client.Collect() _, err := client.Collect()
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
c.Assert(client.Vendor(), qt.IsNil) c.Assert(client.Vendor(), qt.IsNil)
var graphb bytes.Buffer var graphb bytes.Buffer
c.Assert(client.Graph(&graphb), qt.IsNil) c.Assert(client.Graph(&graphb), qt.IsNil)
c.Assert(graphb.String(), qt.Equals, expect) c.Assert(graphb.String(), qt.Equals, expect)
}) })
c.Run("NoVendor", func(c *qt.C) { c.Run("NoVendor", func(c *qt.C) {
mcfg := DefaultModuleConfig mcfg := DefaultModuleConfig
mcfg.NoVendor = "**" mcfg.NoVendor = "**"
client, clean := newClient( client, clean := newClient(
c, func(cfg *ClientConfig) { c, func(cfg *ClientConfig) {
cfg.ModuleConfig = mcfg cfg.ModuleConfig = mcfg
}) }, defaultImport)
defer clean() defer clean()
c.Assert(client.Init(modPath), qt.IsNil) c.Assert(client.Init(modPath), qt.IsNil)
_, err := client.Collect() _, err := client.Collect()
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
c.Assert(client.Vendor(), qt.IsNil) c.Assert(client.Vendor(), qt.IsNil)
var graphb bytes.Buffer var graphb bytes.Buffer
c.Assert(client.Graph(&graphb), qt.IsNil) c.Assert(client.Graph(&graphb), qt.IsNil)
c.Assert(graphb.String(), qt.Equals, expect) c.Assert(graphb.String(), qt.Equals, expect)
}) })
c.Run("VendorClosest", func(c *qt.C) {
mcfg := DefaultModuleConfig
mcfg.VendorClosest = true
client, clean := newClient(
c, func(cfg *ClientConfig) {
cfg.ModuleConfig = mcfg
s := "github.com/gohugoio/hugoTestModules1_darwin
/modh1_1v"
g, _ := glob.GetGlob(s)
cfg.IgnoreVendor = g
}, "modh1v")
defer clean()
c.Assert(client.Init(modPath), qt.IsNil)
_, err := client.Collect()
c.Assert(err, qt.IsNil)
c.Assert(client.Vendor(), qt.IsNil)
var graphb bytes.Buffer
c.Assert(client.Graph(&graphb), qt.IsNil)
c.Assert(graphb.String(), qt.Contains, "github.com/gohugoio/hugoT
estModules1_darwin/modh1_1v@v1.3.0 github.com/gohugoio/hugoTestModules1_darwin/m
odh1_1_1v@v1.1.0+vendor")
})
// https://github.com/gohugoio/hugo/issues/7908 // https://github.com/gohugoio/hugo/issues/7908
c.Run("createThemeDirname", func(c *qt.C) { c.Run("createThemeDirname", func(c *qt.C) {
mcfg := DefaultModuleConfig mcfg := DefaultModuleConfig
client, clean := newClient( client, clean := newClient(
c, func(cfg *ClientConfig) { c, func(cfg *ClientConfig) {
cfg.ModuleConfig = mcfg cfg.ModuleConfig = mcfg
}) }, defaultImport)
defer clean() defer clean()
dirname, err := client.createThemeDirname("foo", false) dirname, err := client.createThemeDirname("foo", false)
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
c.Assert(dirname, qt.Equals, filepath.Join(client.ccfg.ThemesDir, "foo")) c.Assert(dirname, qt.Equals, filepath.Join(client.ccfg.ThemesDir, "foo"))
dirname, err = client.createThemeDirname("../../foo", true) dirname, err = client.createThemeDirname("../../foo", true)
c.Assert(err, qt.IsNil) c.Assert(err, qt.IsNil)
c.Assert(dirname, qt.Equals, filepath.Join(client.ccfg.ThemesDir, "../../foo")) c.Assert(dirname, qt.Equals, filepath.Join(client.ccfg.ThemesDir, "../../foo"))
 End of changes. 10 change blocks. 
9 lines changed or deleted 40 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)