本文整理汇总了Golang中gopkg/in/check/v1.C.Get方法的典型用法代码示例。如果您正苦于以下问题:Golang C.Get方法的具体用法?Golang C.Get怎么用?Golang C.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gopkg/in/check/v1.C
的用法示例。
在下文中一共展示了C.Get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestLoginDischargerError
func (s *suite) TestLoginDischargerError(c *gc.C) {
var d *bakerytest.InteractiveDischarger
d = bakerytest.NewInteractiveDischarger(nil, http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
d.FinishInteraction(w, r, nil, errors.New("test error"))
},
))
defer d.Close()
svc, err := bakery.NewService(bakery.NewServiceParams{
Location: "here",
Locator: d,
})
c.Assert(err, gc.IsNil)
m, err := svc.NewMacaroon("", nil, []checkers.Caveat{{
Location: d.Location(),
Condition: "something",
}})
c.Assert(err, gc.IsNil)
client := httpbakery.NewClient()
client.VisitWebPage = func(u *url.URL) error {
c.Logf("visiting %s", u)
var c httprequest.Client
return c.Get(u.String(), nil)
}
_, err = client.DischargeAll(m)
c.Assert(err, gc.ErrorMatches, `cannot get discharge from ".*": failed to acquire macaroon after waiting: third party refused discharge: test error`)
}
示例2: TestInteractiveDischargerURL
func (s *suite) TestInteractiveDischargerURL(c *gc.C) {
var d *bakerytest.InteractiveDischarger
d = bakerytest.NewInteractiveDischarger(nil, http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, d.URL("/redirect", r), http.StatusFound)
},
))
defer d.Close()
d.Mux.Handle("/redirect", http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
d.FinishInteraction(w, r, nil, nil)
},
))
svc, err := bakery.NewService(bakery.NewServiceParams{
Location: "here",
Locator: d,
})
c.Assert(err, gc.IsNil)
m, err := svc.NewMacaroon("", nil, []checkers.Caveat{{
Location: d.Location(),
Condition: "something",
}})
c.Assert(err, gc.IsNil)
client := httpbakery.NewClient()
client.VisitWebPage = func(u *url.URL) error {
var c httprequest.Client
return c.Get(u.String(), nil)
}
ms, err := client.DischargeAll(m)
c.Assert(err, gc.IsNil)
c.Assert(ms, gc.HasLen, 2)
err = svc.Check(ms, failChecker)
c.Assert(err, gc.IsNil)
}
示例3: TestInteractiveDischarger
func (s *suite) TestInteractiveDischarger(c *gc.C) {
var d *bakerytest.InteractiveDischarger
d = bakerytest.NewInteractiveDischarger(nil, http.HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
d.FinishInteraction(w, r, []checkers.Caveat{
checkers.Caveat{
Condition: "test pass",
},
}, nil)
},
))
defer d.Close()
svc, err := bakery.NewService(bakery.NewServiceParams{
Location: "here",
Locator: d,
})
c.Assert(err, gc.IsNil)
m, err := svc.NewMacaroon("", nil, []checkers.Caveat{{
Location: d.Location(),
Condition: "something",
}})
c.Assert(err, gc.IsNil)
client := httpbakery.NewClient()
client.VisitWebPage = func(u *url.URL) error {
var c httprequest.Client
return c.Get(u.String(), nil)
}
ms, err := client.DischargeAll(m)
c.Assert(err, gc.IsNil)
c.Assert(ms, gc.HasLen, 2)
var r recordingChecker
err = svc.Check(ms, &r)
c.Assert(err, gc.IsNil)
c.Assert(r.caveats, gc.HasLen, 1)
c.Assert(r.caveats[0], gc.Equals, "test pass")
}