mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
tpl/data: Allows user-defined HTTP headers with getJSON and getCSV
Updates #5617
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
06d295427f
commit
150d75738b
@@ -119,6 +119,20 @@ func TestGetCSV(t *testing.T) {
|
||||
c.Assert(got, qt.Not(qt.IsNil), msg)
|
||||
c.Assert(got, qt.DeepEquals, test.expect, msg)
|
||||
|
||||
// Test user-defined headers as well
|
||||
gotHeader, _ := ns.GetCSV(test.sep, test.url, map[string]interface{}{"Accept-Charset": "utf-8", "Max-Forwards": "10"})
|
||||
|
||||
if _, ok := test.expect.(bool); ok {
|
||||
c.Assert(int(ns.deps.Log.LogCounters().ErrorCounter.Count()), qt.Equals, 1)
|
||||
// c.Assert(err, msg, qt.Not(qt.IsNil))
|
||||
c.Assert(got, qt.IsNil)
|
||||
continue
|
||||
}
|
||||
|
||||
c.Assert(err, qt.IsNil, msg)
|
||||
c.Assert(int(ns.deps.Log.LogCounters().ErrorCounter.Count()), qt.Equals, 0)
|
||||
c.Assert(gotHeader, qt.Not(qt.IsNil), msg)
|
||||
c.Assert(gotHeader, qt.DeepEquals, test.expect, msg)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +220,19 @@ func TestGetJSON(t *testing.T) {
|
||||
c.Assert(int(ns.deps.Log.LogCounters().ErrorCounter.Count()), qt.Equals, 0, msg)
|
||||
c.Assert(got, qt.Not(qt.IsNil), msg)
|
||||
c.Assert(got, qt.DeepEquals, test.expect)
|
||||
|
||||
// Test user-defined headers as well
|
||||
gotHeader, _ := ns.GetJSON(test.url, map[string]interface{}{"Accept-Charset": "utf-8", "Max-Forwards": "10"})
|
||||
|
||||
if _, ok := test.expect.(bool); ok {
|
||||
c.Assert(int(ns.deps.Log.LogCounters().ErrorCounter.Count()), qt.Equals, 1)
|
||||
// c.Assert(err, msg, qt.Not(qt.IsNil))
|
||||
continue
|
||||
}
|
||||
|
||||
c.Assert(int(ns.deps.Log.LogCounters().ErrorCounter.Count()), qt.Equals, 0, msg)
|
||||
c.Assert(gotHeader, qt.Not(qt.IsNil), msg)
|
||||
c.Assert(gotHeader, qt.DeepEquals, test.expect)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user