Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-08-07 23:29:27 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2016-09-06 18:32:18 +0300
commit506e131f281be411c94b411324ef8bffc352cb66 (patch)
treeffdd962dcb2aac25aec1ada6ed31375a08c7ba55 /hugolib/embedded_shortcodes_test.go
parent54141f71dd0ffbd2af326581b78ecafe7f054f51 (diff)
Fix the shortcode ref tests
See #2309
Diffstat (limited to 'hugolib/embedded_shortcodes_test.go')
-rw-r--r--hugolib/embedded_shortcodes_test.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/hugolib/embedded_shortcodes_test.go b/hugolib/embedded_shortcodes_test.go
index cebef0b8b..7dda21d41 100644
--- a/hugolib/embedded_shortcodes_test.go
+++ b/hugolib/embedded_shortcodes_test.go
@@ -19,11 +19,13 @@ import (
"os"
"path/filepath"
"regexp"
+ "strings"
"testing"
"github.com/spf13/hugo/helpers"
"github.com/spf13/hugo/tpl"
"github.com/spf13/viper"
+ "github.com/stretchr/testify/require"
)
const (
@@ -37,6 +39,9 @@ func TestShortcodeCrossrefs(t *testing.T) {
}
func doTestShortcodeCrossrefs(t *testing.T, relative bool) {
+ testCommonResetState()
+ viper.Set("baseURL", baseURL)
+
var refShortcode string
var expectedBase string
@@ -50,21 +55,20 @@ func doTestShortcodeCrossrefs(t *testing.T, relative bool) {
path := filepath.FromSlash("blog/post.md")
in := fmt.Sprintf(`{{< %s "%s" >}}`, refShortcode, path)
+
+ writeSource(t, "content/"+path, simplePageWithURL+": "+in)
+
expected := fmt.Sprintf(`%s/simple/url/`, expectedBase)
- templ := tpl.New()
- p, _ := pageFromString(simplePageWithURL, path)
- p.Node.Site = newSiteInfoDefaultLanguage(
- helpers.SanitizeURLKeepTrailingSlash(baseURL),
- p)
+ sites, err := newHugoSitesDefaultLanguage()
+ require.NoError(t, err)
- output, err := HandleShortcodes(in, p, templ)
+ require.NoError(t, sites.Build(BuildCfg{}))
+ require.Len(t, sites.Sites[0].Pages, 1)
- if err != nil {
- t.Fatal("Handle shortcode error", err)
- }
+ output := string(sites.Sites[0].Pages[0].Content)
- if output != expected {
+ if !strings.Contains(output, expected) {
t.Errorf("Got\n%q\nExpected\n%q", output, expected)
}
}