Upgrade Instagram shortcode

Fixes #7879
This commit is contained in:
Bjørn Erik Pedersen
2021-06-07 12:45:00 +02:00
parent 12530519d8
commit 9b5debe4b8
7 changed files with 158 additions and 92 deletions

View File

@@ -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
---