// Copyright 2019 The Hugo Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package hugolib
import (
"fmt"
"math/rand"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/gohugoio/hugo/modules/npm"
"github.com/gohugoio/hugo/common/loggers"
"github.com/spf13/afero"
"github.com/gohugoio/hugo/hugofs/files"
"github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/hugofs"
qt "github.com/frankban/quicktest"
"github.com/gohugoio/testmodBuilder/mods"
"github.com/spf13/viper"
)
func TestHugoModulesVariants(t *testing.T) {
if !isCI() {
t.Skip("skip (relative) long running modules test when running locally")
}
config := `
baseURL="https://example.org"
workingDir = %q
[module]
[[module.imports]]
path="github.com/gohugoio/hugoTestModule2"
%s
`
createConfig := func(workingDir, moduleOpts string) string {
return fmt.Sprintf(config, workingDir, moduleOpts)
}
newTestBuilder := func(t testing.TB, moduleOpts string) (*sitesBuilder, func()) {
b := newTestSitesBuilder(t)
tempDir, clean, err := htesting.CreateTempDir(hugofs.Os, "hugo-modules-variants")
b.Assert(err, qt.IsNil)
workingDir := filepath.Join(tempDir, "myhugosite")
b.Assert(os.MkdirAll(workingDir, 0777), qt.IsNil)
b.Fs = hugofs.NewDefault(viper.New())
b.WithWorkingDir(workingDir).WithConfigFile(&