summaryrefslogtreecommitdiffstats
path: root/hugolib/embedded_shortcodes_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-06-07 12:45:00 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-06-08 10:30:45 +0200
commit9b5debe4b820132759cfdf7bff7fe9c1ad0a6bb1 (patch)
treea202477925fc879db34375292ebe432b74d3acd7 /hugolib/embedded_shortcodes_test.go
parent12530519d8fb4513c9c18a6494099b7dff8e4fd4 (diff)
Upgrade Instagram shortcode
Fixes #7879
Diffstat (limited to 'hugolib/embedded_shortcodes_test.go')
-rw-r--r--hugolib/embedded_shortcodes_test.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/hugolib/embedded_shortcodes_test.go b/hugolib/embedded_shortcodes_test.go
index 90f2685af..9fb25e22a 100644
--- a/hugolib/embedded_shortcodes_test.go
+++ b/hugolib/embedded_shortcodes_test.go
@@ -372,12 +372,16 @@ func TestShortcodeInstagram(t *testing.T) {
} {
// overload getJSON to return mock API response from Instagram
instagramFuncMap := template.FuncMap{
- "getJSON": func(urlParts ...string) interface{} {
+ "getJSON": func(args ...interface{}) interface{} {
+ headers := args[len(args)-1].(map[string]interface{})
+ auth := headers["Authorization"]
+ if auth != "Bearer dummytoken" {
+ return fmt.Errorf("invalid access token: %q", auth)
+ }
var v interface{}
err := json.Unmarshal([]byte(this.resp), &v)
if err != nil {
- t.Fatalf("[%d] unexpected error in json.Unmarshal: %s", i, err)
- return err
+ return fmt.Errorf("[%d] unexpected error in json.Unmarshal: %s", i, err)
}
return v
},
@@ -388,6 +392,8 @@ func TestShortcodeInstagram(t *testing.T) {
th = newTestHelper(cfg, fs, t)
)
+ cfg.Set("services.instagram.accessToken", "dummytoken")
+
writeSource(t, fs, filepath.Join("content", "simple.md"), fmt.Sprintf(`---
title: Shorty
---