package filecache
import (
+ "errors"
"fmt"
"path"
"path/filepath"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/config"
- "errors"
-
"github.com/mitchellh/mapstructure"
"github.com/spf13/afero"
)
// Resolves :resourceDir => /myproject/resources etc., :cacheDir => ...
func resolveDirPlaceholder(fs afero.Fs, bcfg config.BaseConfig, placeholder string) (cacheDir string, isResource bool, err error) {
-
switch strings.ToLower(placeholder) {
case ":resourcedir":
return "", true, nil
counter := 0
err := afero.Walk(c.Fs, "", func(name string, info os.FileInfo, err error) error {
-
if info == nil {
return nil
}
if info.IsDir() {
f, err := c.Fs.Open(name)
-
if err != nil {
// This cache dir may not exist.
return nil
pkg,
tt.Methods.List)...)
}
-
} else {
// Embedded, but in a different file/package. Return the
// package.Name and deal with that later.
[]any{&tstSlicerIn1{"c"}},
testSlicerInterfaces{&tstSlicerIn1{"a"}, &tstSlicerIn1{"b"}, &tstSlicerIn1{"c"}},
},
- //https://github.com/gohugoio/hugo/issues/5361
+ // https://github.com/gohugoio/hugo/issues/5361
{
[]string{"a", "b"},
[]any{tstSlicers{&tstSlicer{"a"}, &tstSlicer{"b"}}},
from []any
expected any
}{
- {[][]string{{"a", "b"}},
+ {
+ [][]string{{"a", "b"}},
[]any{[]string{"c", "d"}},
[][]string{
{"a", "b"},
{"c", "d"},
},
},
- {[][]string{{"a", "b"}},
+ {
+ [][]string{{"a", "b"}},
[]any{[]string{"c", "d"}, []string{"e", "f"}},
[][]string{
{"a", "b"},
{"e", "f"},
},
},
- {[][]string{{"a", "b"}},
+ {
+ [][]string{{"a", "b"}},
[]any{[]int{1, 2}},
false,
},
c.Assert(result, qt.DeepEquals, test.expected)
}
}
-
}
func TestAppendShouldMakeACopyOfTheInputSlice(t *testing.T) {
result[i] = s
}
return result
-
}
type SortedStringSlice []string
c.Assert(s.Count("b"), qt.Equals, 3)
c.Assert(s.Count("z"), qt.Equals, 0)
c.Assert(s.Count("a"), qt.Equals, 1)
-
}
"errors"
"fmt"
"io"
- "regexp"
- "strings"
-
"os"
"os/exec"
+ "regexp"
+ "strings"
"github.com/cli/safeexec"
"github.com/gohugoio/hugo/config"
}
return cm.command(arg...)
-
}
// Npx is a convenience method to create a Runner running npx --no-install <name> <args.
c.Assert(f.Format(june06, ":time_long"), qt.Equals, "02:09:37 UTC")
c.Assert(f.Format(june06, ":time_medium"), qt.Equals, "02:09:37")
c.Assert(f.Format(june06, ":time_short"), qt.Equals, "02:09")
-
})
c.Run("Custom layouts English", func(c *qt.C) {
c.Assert(f.Format(june06, ":time_long"), qt.Equals, "2:09:37 am UTC")
c.Assert(f.Format(june06, ":time_medium"), qt.Equals, "2:09:37 am")
c.Assert(f.Format(june06, ":time_short"), qt.Equals, "2:09 am")
-
})
c.Run("English", func(c *qt.C) {
c.Assert(tr.MonthWide(date.Month()), qt.Equals, monthWideNorway)
c.Assert(f.Format(date, "January"), qt.Equals, monthWideNorway)
}
-
})
-
}
func BenchmarkTimeFormatter(b *testing.B) {
v, found = LookupEqualFold(m2, "b")
c.Assert(found, qt.IsTrue)
c.Assert(v, qt.Equals, "bv")
-
}
"a": "av",
"c": "cv",
})
-
}
func TestParamsIsZero(t *testing.T) {
// If ParseRequestURI fails, the input is just converted to OS specific slashes and returned.
func UrlToFilename(s string) (string, bool) {
u, err := url.ParseRequestURI(s)
-
if err != nil {
return filepath.FromSlash(s), false
}
c := qt.New(t)
c.Assert(collected, qt.DeepEquals, []string{"line 1\n", "line 2\n", "\n", "line 3"})
-
}
func BenchmarkVisitLinesAfter(b *testing.B) {
for i := 0; i < b.N; i++ {
VisitLinesAfter(lines, func(s string) {
-
})
-
}
-
}
default:
return nil, fmt.Errorf("failed to convert %T to a string slice", v)
}
-
}
// TypeToString converts v to a string if it's a valid string type.
c.Assert(ToDuration("200"), qt.Equals, 200*time.Millisecond)
c.Assert(ToDuration("4m"), qt.Equals, 4*time.Minute)
c.Assert(ToDuration("asdfadf"), qt.Equals, time.Duration(0))
-
}
title = "Svenska"
weight = 4
`
- if err := os.WriteFile(configFilename, []byte(config), 0666); err != nil {
+ if err := os.WriteFile(configFilename, []byte(config), 0o666); err != nil {
b.Fatal(err)
}
d := ConfigSourceDescriptor{
}
return cfg, dirnames, nil
-
}
var keyAliases maps.KeyRenamer
}
return false
})
-
}
func (c *defaultConfigProvider) getNestedKeyAndMap(key string, create bool) (string, maps.Params) {
if v := stringToGibabyte(mem); v > 0 {
return v
}
-
}
// There is a FreeMemory function, but as the kernel in most situations
c.Assert(w.Accept("bar"), qt.IsTrue)
c.Assert(w.Accept("mbar"), qt.IsFalse)
})
-
}
package deploy
import (
+ "errors"
"fmt"
"regexp"
- "errors"
-
"github.com/gobwas/glob"
"github.com/gohugoio/hugo/config"
hglob "github.com/gohugoio/hugo/hugofs/glob"
// DecodeConfig creates a config from a given Hugo configuration.
func DecodeConfig(cfg config.Provider) (DeployConfig, error) {
-
dcfg := DefaultConfig
if !cfg.IsSet(deploymentConfigKey) {
)
func TestExtractMinorVersionFromGoTag(t *testing.T) {
-
c := qt.New(t)
c.Assert(extractMinorVersionFromGoTag("go1.17"), qt.Equals, 17)
c.Assert(extractMinorVersionFromGoTag("go1.16.7"), qt.Equals, 16)
c.Assert(extractMinorVersionFromGoTag("go1.17beta1"), qt.Equals, 17)
c.Assert(extractMinorVersionFromGoTag("asdfadf"), qt.Equals, -1)
-
}
ReportDuplicates() string
}
-var (
- _ FilesystemUnwrapper = (*createCountingFs)(nil)
-)
+var _ FilesystemUnwrapper = (*createCountingFs)(nil)
func NewCreateCountingFs(fs afero.Fs) afero.Fs {
return &createCountingFs{Fs: fs, fileCount: make(map[string]int)}
}
func BenchmarkGetGlob(b *testing.B) {
-
runBench := func(name string, cache *globCache, search string) {
b.Run(name, func(b *testing.B) {
g, err := GetGlob("**/foo")
IntegrationTestConfig{
T: t,
TxtarString: files,
- //LogLevel: logg.LevelTrace,
- //Verbose: true,
+ // LogLevel: logg.LevelTrace,
+ // Verbose: true,
},
).Build()
tempDir := os.TempDir()
cacheDir := filepath.Join(tempDir, "hugocache")
- if err := os.MkdirAll(cacheDir, 0777); err != nil {
+ if err := os.MkdirAll(cacheDir, 0o777); err != nil {
return nil, err
}
cfg.Set("cacheDir", cacheDir)
fs := afero.NewOsFs()
- if err := afero.WriteFile(fs, filepath.Join(tempDir, "hugo.toml"), []byte(configToml), 0644); err != nil {
+ if err := afero.WriteFile(fs, filepath.Join(tempDir, "hugo.toml"), []byte(configToml), 0o644); err != nil {
return nil, err
}
- if err := afero.WriteFile(fs, filepath.Join(tempDir, "go.mod"), []byte(goMod), 0644); err != nil {
+ if err := afero.WriteFile(fs, filepath.Join(tempDir, "go.mod"), []byte(goMod), 0o644); err != nil {
return nil, err
}
return nil, err
}
return conf.Base, err
-
}
func TestI18n(t *testing.T) {
c := qt.New(t)
- //https://github.com/gohugoio/hugo/issues/7804
+ // https://github.com/gohugoio/hugo/issues/7804
c.Run("pt-br should be case insensitive", func(c *qt.C) {
b := newTestSitesBuilder(c)
langCode := func() string {
menus := b.H.Sites[0].Menus()
c.Assert(menus, qt.HasLen, 1)
-
})
}
func TestLanguageNumberFormatting(t *testing.T) {
-
b := newTestSitesBuilder(t)
b.WithConfigFile("toml", `
baseURL = "https://example.org"
)
func TestCollator(t *testing.T) {
-
c := qt.New(t)
var wg sync.WaitGroup
}()
}
wg.Wait()
-
}
func BenchmarkCollator(b *testing.B) {
}
})
})
-
}
r = true
_, err = i.Do(context.Background())
c.Assert(err, qt.IsNil)
-
}
}
return ast.WalkContinue, nil
-
})
-
}
func (a *attrParser) Open(parent ast.Node, reader text.Reader, pc parser.Context) (ast.Node, parser.State) {
if attrs, ok := parser.ParseAttributes(reader); ok {
// add attributes
- var node = &attributesBlock{
+ node := &attributesBlock{
BaseBlock: ast.BaseBlock{},
}
for _, attr := range attrs {
type transformer struct{}
func (a *transformer) Transform(node *ast.Document, reader text.Reader, pc parser.Context) {
- var attributes = make([]ast.Node, 0, 500)
+ attributes := make([]ast.Node, 0, 500)
ast.Walk(node, func(node ast.Node, entering bool) (ast.WalkStatus, error) {
if entering && node.Kind() == kindAttributesBlock {
// Attributes for fenced code blocks are handled in their own extension,
func ExternallyRenderContent(
cfg converter.ProviderConfig,
ctx converter.DocumentContext,
- content []byte, binaryName string, args []string) ([]byte, error) {
+ content []byte, binaryName string, args []string,
+) ([]byte, error) {
logger := cfg.Logger
if strings.Contains(binaryName, "/") {
c.Assert(err, qt.IsNil)
c.Assert(conf.Goldmark.Extensions.Typographer.Disable, qt.Equals, false)
c.Assert(conf.Goldmark.Extensions.Typographer.Ellipsis, qt.Equals, "…")
-
})
-
}
// Provider is the package entry point.
var Provider converter.ProviderProvider = provider{}
-type provider struct {
-}
+type provider struct{}
func (p provider) New(cfg converter.ProviderConfig) (converter.Provider, error) {
return converter.NewProvider("pandoc", func(ctx converter.DocumentContext) (converter.Converter, error) {
// Provider is the package entry point.
var Provider converter.ProviderProvider = provider{}
-type provider struct {
-}
+type provider struct{}
func (p provider) New(cfg converter.ProviderConfig) (converter.Provider, error) {
return converter.NewProvider("rst", func(ctx converter.DocumentContext) (converter.Converter, error) {
}
func BenchmarkToc(b *testing.B) {
-
newTocs := func(n int) []*Fragments {
var tocs []*Fragments
for i := 0; i < n; i++ {
toc.ToHTML(1, -1, false)
}
})
-
}
OctetType Type
}
-var (
- Builtin = BuiltinTypes{
- CalendarType: Type{Type: "text/calendar"},
- CSSType: Type{Type: "text/css"},
- SCSSType: Type{Type: "text/x-scss"},
- SASSType: Type{Type: "text/x-sass"},
- CSVType: Type{Type: "text/csv"},
- HTMLType: Type{Type: "text/html"},
- JavascriptType: Type{Type: "text/javascript"},
- TypeScriptType: Type{Type: "text/typescript"},
- TSXType: Type{Type: "text/tsx"},
- JSXType: Type{Type: "text/jsx"},
-
- JSONType: Type{Type: "application/json"},
- WebAppManifestType: Type{Type: "application/manifest+json"},
- RSSType: Type{Type: "application/rss+xml"},
- XMLType: Type{Type: "application/xml"},
- SVGType: Type{Type: "image/svg+xml"},
- TextType: Type{Type: "text/plain"},
- TOMLType: Type{Type: "application/toml"},
- YAMLType: Type{Type: "application/yaml"},
-
- // Common image types
- PNGType: Type{Type: "image/png"},
- JPEGType: Type{Type: "image/jpeg"},
- GIFType: Type{Type: "image/gif"},
- TIFFType: Type{Type: "image/tiff"},
- BMPType: Type{Type: "image/bmp"},
- WEBPType: Type{Type: "image/webp"},
-
- // Common font types
- TrueTypeFontType: Type{Type: "font/ttf"},
- OpenTypeFontType: Type{Type: "font/otf"},
-
- // Common document types
- PDFType: Type{Type: "application/pdf"},
- MarkdownType: Type{Type: "text/markdown"},
-
- // Common video types
- AVIType: Type{Type: "video/x-msvideo"},
- MPEGType: Type{Type: "video/mpeg"},
- MP4Type: Type{Type: "video/mp4"},
- OGGType: Type{Type: "video/ogg"},
- WEBMType: Type{Type: "video/webm"},
- GPPType: Type{Type: "video/3gpp"},
-
- // Web assembly.
- WasmType: Type{Type: "application/wasm"},
-
- OctetType: Type{Type: "application/octet-stream"},
- }
-)
+var Builtin = BuiltinTypes{
+ CalendarType: Type{Type: "text/calendar"},
+ CSSType: Type{Type: "text/css"},
+ SCSSType: Type{Type: "text/x-scss"},
+ SASSType: Type{Type: "text/x-sass"},
+ CSVType: Type{Type: "text/csv"},
+ HTMLType: Type{Type: "text/html"},
+ JavascriptType: Type{Type: "text/javascript"},
+ TypeScriptType: Type{Type: "text/typescript"},
+ TSXType: Type{Type: "text/tsx"},
+ JSXType: Type{Type: "text/jsx"},
+
+ JSONType: Type{Type: "application/json"},
+ WebAppManifestType: Type{Type: "application/manifest+json"},
+ RSSType: Type{Type: "application/rss+xml"},
+ XMLType: Type{Type: "application/xml"},
+ SVGType: Type{Type: "image/svg+xml"},
+ TextType: Type{Type: "text/plain"},
+ TOMLType: Type{Type: "application/toml"},
+ YAMLType: Type{Type: "application/yaml"},
+
+ // Common image types
+ PNGType: Type{Type: "image/png"},
+ JPEGType: Type{Type: "image/jpeg"},
+ GIFType: Type{Type: "image/gif"},
+ TIFFType: Type{Type: "image/tiff"},
+ BMPType: Type{Type: "image/bmp"},
+ WEBPType: Type{Type: "image/webp"},
+
+ // Common font types
+ TrueTypeFontType: Type{Type: "font/ttf"},
+ OpenTypeFontType: Type{Type: "font/otf"},
+
+ // Common document types
+ PDFType: Type{Type: "application/pdf"},
+ MarkdownType: Type{Type: "text/markdown"},
+
+ // Common video types
+ AVIType: Type{Type: "video/x-msvideo"},
+ MPEGType: Type{Type: "video/mpeg"},
+ MP4Type: Type{Type: "video/mp4"},
+ OGGType: Type{Type: "video/ogg"},
+ WEBMType: Type{Type: "video/webm"},
+ GPPType: Type{Type: "video/3gpp"},
+
+ // Web assembly.
+ WasmType: Type{Type: "application/wasm"},
+
+ OctetType: Type{Type: "application/octet-stream"},
+}
var defaultMediaTypesConfig = map[string]any{
"text/calendar": map[string]any{"suffixes": []string{"ics"}},
conf := testconfig.GetTestConfigs(nil, v).Base.Minify
c.Assert(conf.Tdewolff.CSS.Precision, qt.Equals, 3)
-
}
// Issue 9456
KeepDocumentTags: true,
KeepEndTags: false,
KeepQuotes: false,
- KeepWhitespace: false},
+ KeepWhitespace: false,
+ },
)
-
}
"bytes"
"context"
"encoding/json"
+ "errors"
"fmt"
"io"
"os"
"github.com/gohugoio/hugo/common/hugio"
- "errors"
-
"github.com/spf13/afero"
)
if err := c.rmVendorDir(vendorDir); err != nil {
return err
}
- if err := c.fs.MkdirAll(vendorDir, 0755); err != nil {
+ if err := c.fs.MkdirAll(vendorDir, 0o755); err != nil {
return err
}
} else {
targetDir := filepath.Dir(targetFilename)
- if err := c.fs.MkdirAll(targetDir, 0755); err != nil {
+ if err := c.fs.MkdirAll(targetDir, 0o755); err != nil {
return fmt.Errorf("failed to make target dir: %w", err)
}
}
if modulesContent.Len() > 0 {
- if err := afero.WriteFile(c.fs, filepath.Join(vendorDir, vendorModulesFilename), modulesContent.Bytes(), 0666); err != nil {
+ if err := afero.WriteFile(c.fs, filepath.Join(vendorDir, vendorModulesFilename), modulesContent.Bytes(), 0o666); err != nil {
return err
}
}
return err
}
if data != nil {
- if err := afero.WriteFile(c.fs, filepath.Join(c.ccfg.WorkingDir, name), data, 0666); err != nil {
+ if err := afero.WriteFile(c.fs, filepath.Join(c.ccfg.WorkingDir, name), data, 0o666); err != nil {
return err
}
}
func (c *Client) runGo(
ctx context.Context,
stdout io.Writer,
- args ...string) error {
+ args ...string,
+) error {
if c.goBinaryStatus != 0 {
return nil
}
c.Assert(imp.Mounts[1].Source, qt.Equals, "src/markdown/blog")
c.Assert(imp.Mounts[1].Target, qt.Equals, "content/blog")
c.Assert(imp.Mounts[1].Lang, qt.Equals, "en")
-
})
c.Run("Replacements", func(c *qt.C) {
var _ Module = (*moduleAdapter)(nil)
type Module interface {
-
// Optional config read from the configFilename above.
Cfg() config.Provider
}
return *m.gomod.Time
-
}
func (m *moduleAdapter) Watch() bool {
return pm, nil
}
- var wrapErr = func(err error) error {
+ wrapErr := func(err error) error {
return fmt.Errorf("unable to process menus for page %q: %w", p.Path(), err)
}
func NewMenuQueryProvider(
pagem PageMenusGetter,
sitem MenusGetter,
- p Page) MenuQueryProvider {
+ p Page,
+) MenuQueryProvider {
return &pageMenus{
p: p,
pagem: pagem,
name string
d layouts.LayoutDescriptor
}{
-
// Taxonomy layouts.LayoutDescriptor={categories category taxonomy en false Type Section
{"Single page in \"posts\" section", layouts.LayoutDescriptor{Kind: "page", Type: "posts", OutputFormatName: "html", Suffix: "html"}},
{"Base template for single page in \"posts\" section", layouts.LayoutDescriptor{Baseof: true, Kind: "page", Type: "posts", OutputFormatName: "html", Suffix: "html"}},
c.Assert(CalendarFormat.IsHTML, qt.Equals, false)
c.Assert(len(DefaultFormats), qt.Equals, 11)
-
}
func TestGetFormatByName(t *testing.T) {
"guid": "https://example.com/2021/11/30/example-title/",
"link": "https://example.com/2021/11/30/example-title/",
"pubDate": "Tue, 30 Nov 2021 15:00:00 +0000",
- "title": "Example title"},
+ "title": "Example title",
+ },
"language": "en-us",
"lastBuildDate": "Fri, 08 Jan 2021 14:44:10 +0000",
"link": []any{"https://example.com/", map[string]any{
"-href": "https://example.com/feed.xml",
"-rel": "self",
- "-type": "application/rss+xml"}},
+ "-type": "application/rss+xml",
+ }},
"title": "Example feed",
- }}
+ },
+ }
d := Default
m, err := d.Unmarshal([]byte(xmlDoc), XML)
c.Assert(err, qt.IsNil)
c.Assert(m, qt.DeepEquals, expect)
-
}
+
func TestUnmarshalToMap(t *testing.T) {
c := qt.New(t)
c.Assert(Item{low: 0, high: len(source)}.ValTyped(source), qt.Equals, "truex")
source = []byte("xtrue")
c.Assert(Item{low: 0, high: len(source)}.ValTyped(source), qt.Equals, "xtrue")
-
}
elementStepNum int // step number in element
paramElements int // number of elements (name + value = 2) found first
openShortcodes map[string]bool // set of shortcodes in open state
-
}
// Shortcode syntax
}
return s
-
}
// isClosedByTag reports whether b ends with a closing tag for tagName.
}
return bytes.EqualFold(tagName, b[lo:hi])
-
}
func isSpace(b byte) bool {
}">
</div>
</body>`, f("body div", "class1 class2 class3", "")},
- {"AlpineJS bind 2", `<div x-bind:class="{ 'bg-black': filter.checked }" class="inline-block mr-1 mb-2 rounded bg-gray-300 px-2 py-2">FOO</div>`,
+ {
+ "AlpineJS bind 2", `<div x-bind:class="{ 'bg-black': filter.checked }" class="inline-block mr-1 mb-2 rounded bg-gray-300 px-2 py-2">FOO</div>`,
f("div", "bg-black bg-gray-300 inline-block mb-2 mr-1 px-2 py-2 rounded", ""),
},
{"AlpineJS bind 3", `<div x-bind:class="{ 'text-gray-800': !checked, 'text-white': checked }"></div>`, f("div", "text-gray-800 text-white", "")},
<div id="b" class="foo">d</div>`, f("div form", "foo", "a b")},
{"Big input, multibyte runes", strings.Repeat(`神真美好 `, rnd.Intn(500)+1) + "<div id=\"神真美好\" class=\"foo\">" + strings.Repeat(`神真美好 `, rnd.Intn(100)+1) + " <span>神真美好</span>", f("div span", "foo", "神真美好")},
} {
-
for _, variant := range []struct {
minify bool
}{
})
}
}
-
}
func TestEndsWithTag(t *testing.T) {
c.Assert(got, qt.Equals, test.expect)
})
}
-
}
func BenchmarkElementsCollectorWriter(b *testing.B) {
))
for i := 0; i < b.N; i++ {
fmt.Fprint(w, benchHTML)
-
}
}
c.Assert(hasKeyword("tags", "b"), qt.Equals, false)
c.Assert(hasKeyword("tags", "d"), qt.Equals, true)
c.Assert(hasKeyword("keywords", "b"), qt.Equals, true)
-
}
func TestSearch(t *testing.T) {
r, g, b, a := c.RGBA()
rgba := color.RGBA{uint8(r), uint8(g), uint8(b), uint8(a)}
return fmt.Sprintf("#%.2x%.2x%.2x", rgba.R, rgba.G, rgba.B)
-
}
func hexStringToColor(s string) (color.Color, error) {
developmentTestSite := testSite{h: hugo.NewInfo(testConfig{environment: "development"}, nil)}
productionTestSite := testSite{h: hugo.NewInfo(testConfig{environment: "production"}, nil)}
- p1, p2, p3 :=
- &testPage{path: "/p1", kind: "section", lang: "en", site: developmentTestSite},
+ p1, p2, p3 := &testPage{path: "/p1", kind: "section", lang: "en", site: developmentTestSite},
&testPage{path: "p2", kind: "page", lang: "no", site: productionTestSite},
&testPage{path: "p3", kind: "page", lang: "en"}
got, err = DecodeCascadeConfig(nil)
c.Assert(err, qt.IsNil)
c.Assert(got, qt.IsNotNil)
-
}
type testConfig struct {
c.Assert(err, isErr)
c.Assert(got, qt.DeepEquals, test.want)
})
-
}
}
c.Assert(err, qt.IsNil)
c.Assert(req.Method, qt.Equals, "GET")
c.Assert(req.Header["User-Agent"], qt.DeepEquals, []string{"foo"})
-
}
func TestCalculateResourceID(t *testing.T) {
b.AssertLogMatches(`Dart Sass: foo`)
b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:1:0: bar`)
-
}
func TestTransformErrors(t *testing.T) {
b.Assert(fe.ErrorContext(), qt.IsNotNil)
b.Assert(fe.ErrorContext().Lines, qt.DeepEquals, []string{" $maincolor #eee;", "", "body {", "\tcolor: $maincolor;", "}"})
b.Assert(fe.ErrorContext().ChromaLexer, qt.Equals, "scss")
-
})
c.Run("error in import", func(c *qt.C) {
b.Assert(fe.ErrorContext(), qt.IsNotNil)
b.Assert(fe.ErrorContext().Lines, qt.DeepEquals, []string{"/* comment line 1 */", "$foocolor #ccc;", "", "foo {"})
b.Assert(fe.ErrorContext().ChromaLexer, qt.Equals, "scss")
-
})
-
}
func TestOptionVars(t *testing.T) {
b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:12:0: number`)
b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:13:0: number`)
b.AssertLogMatches(`Dart Sass: .*assets.*main.scss:14:0: number`)
-
}
}
return res.Transform(&toCSSTransformation{c: c, options: internalOptions})
-
}
type toCSSTransformation struct {
b.Assert(fe.ErrorContext(), qt.IsNotNil)
b.Assert(fe.ErrorContext().Lines, qt.DeepEquals, []string{"/* comment line 4 */", "", "$maincolor #eee;", "", "body {"})
b.Assert(fe.ErrorContext().ChromaLexer, qt.Equals, "scss")
-
})
c.Run("error in import", func(c *qt.C) {
b.Assert(fe.ErrorContext(), qt.IsNotNil)
b.Assert(fe.ErrorContext().Lines, qt.DeepEquals, []string{"/* comment line 1 */", "$foocolor #ccc;", "", "foo {"})
b.Assert(fe.ErrorContext().ChromaLexer, qt.Equals, "scss")
-
})
-
}
func TestOptionVars(t *testing.T) {
}
// Namespace provides template functions for the "cast" namespace.
-type Namespace struct {
-}
+type Namespace struct{}
// ToInt converts v to an int.
func (ns *Namespace) ToInt(v any) (int, error) {
package collections
import (
+ "errors"
"fmt"
"reflect"
"strings"
"github.com/gohugoio/hugo/common/hreflect"
"github.com/gohugoio/hugo/common/maps"
-
- "errors"
)
// Merge creates a copy of the final parameter in params and merges the preceding
package collections
import (
+ "errors"
"fmt"
"reflect"
- "errors"
-
"github.com/mitchellh/hashstructure"
)
j := rand.Intn(i + 1)
seq[i], seq[j] = seq[j], seq[i]
}
- //results, err = ns.Where(context.Background(), test.seq, test.key, test.op, test.match)
+ // results, err = ns.Where(context.Background(), test.seq, test.key, test.op, test.match)
runOps := func(b *testing.B, op, match string) {
_, err := ns.Where(ctx, seq, "foo", op, match)
if err != nil {
runOps(b, "like", "^bar")
}
})
-
}
return "", err
}
- var encoding = "hex"
+ encoding := "hex"
if len(e) > 0 && e[0] != nil {
encoding, err = cast.ToStringE(e[0])
if err != nil {
default:
return "", fmt.Errorf("%q is not a supported encoding method", encoding)
}
-
}
const name = "css"
// Namespace provides template functions for the "css" namespace.
-type Namespace struct {
-}
+type Namespace struct{}
// Quoted returns a string that needs to be quoted in CSS.
func (ns *Namespace) Quoted(v any) css.QuotedString {
false,
},
} {
-
c.Run(test.url, func(c *qt.C) {
msg := qt.Commentf("Test %d", i)
c.Assert(got, qt.Not(qt.IsNil), msg)
c.Assert(got, qt.DeepEquals, test.expect, msg)
})
-
}
}
map[string]any{"gomeetup": []any{"Sydney", "San Francisco", "Stockholm"}},
},
} {
-
c.Run(test.url, func(c *qt.C) {
-
msg := qt.Commentf("Test %d", i)
ns := newTestNs()
c.Assert(int(ns.deps.Log.LoggCount(logg.LevelError)), qt.Equals, 0, msg)
c.Assert(got, qt.Not(qt.IsNil), msg)
c.Assert(got, qt.DeepEquals, test.expect)
-
})
}
}
},
},
} {
-
c.Run(test.name, func(c *qt.C) {
-
ns := newTestNs()
// Setup HTTP test server
c.Assert(r.URL.String(), qt.Equals, "http://gohugo.io/api?foo")
w.Write([]byte("{}"))
r.Header.Write(&headers)
-
})
defer func() { srv.Close() }()
_, err := ns.GetCSV(",", args...)
return err
})
-
})
-
}
}
package images
import (
+ "errors"
"image"
"sync"
- "errors"
-
"github.com/bep/overlayfs"
"github.com/gohugoio/hugo/resources/images"
// cast path to string for afero.WriteFile
sp, err := cast.ToStringE(test.path)
c.Assert(err, qt.IsNil)
- afero.WriteFile(ns.deps.Fs.Source, filepath.Join(bcfg.WorkingDir(), sp), test.input, 0755)
+ afero.WriteFile(ns.deps.Fs.Source, filepath.Join(bcfg.WorkingDir(), sp), test.input, 0o755)
result, err := ns.Config(test.path)
qt "github.com/frankban/quicktest"
)
-type Test struct {
-}
+type Test struct{}
func (t *Test) MyTestMethod() string {
return "abcde"
return
}
return
-
}
func (ns *Namespace) toFloatsE(v any) ([]float64, bool, error) {
// extraneous slashes are removed.
func (ns *Namespace) Clean(path any) (string, error) {
spath, err := cast.ToStringE(path)
-
if err != nil {
return "", err
}
}
return re.FindAllStringSubmatch(conv, n), nil
-
}
// ReplaceRE returns a copy of s, replacing all matches of the regular
c.Check(result, qt.DeepEquals, test.expect)
}
}
+
func TestReplaceRE(t *testing.T) {
t.Parallel()
c := qt.New(t)
ns.Truncate(10, "I have a <a href='/markdown'>Markdown link</a> inside")
}
})
-
}
}
})
- //Issue #9084
+ // Issue #9084
c.Run("TZ America/Los_Angeles", func(c *qt.C) {
c.Parallel()
c.Assert(err, qt.IsNil)
c.Assert(d, qt.Equals, "11:00:00 am Pacific Daylight Time")
-
})
-
}
func TestDuration(t *testing.T) {
const numTemplateVariants = 3
type shortcodeVariant struct {
-
// The possible variants: lang, outFormat, suffix
// gtag
// gtag.html
import (
"bytes"
- "strings"
-
"errors"
+ "strings"
"github.com/gohugoio/hugo/parser"
"github.com/gohugoio/hugo/parser/metadecoders"
// of any ./ or ../ elements. If the argument list is empty, JoinPath returns
// an empty string.
func (ns *Namespace) JoinPath(elements ...any) (string, error) {
-
if len(elements) == 0 {
return "", nil
}
}
return &itemToWatch{filename: filename, left: r}, nil
-
}
func (item *itemToWatch) checkForChanges() ([]fsnotify.Event, error) {
}
return evs, nil
-
}
func checkChange(fi1, fi2 os.FileInfo) fsnotify.Op {