mirror of
https://github.com/MontFerret/ferret.git
synced 2025-01-12 03:19:45 +02:00
Merge remote-tracking branch 'upstream/master' into cleanup/fix-naming-convention
This commit is contained in:
commit
a460cfcf6c
@ -3,6 +3,7 @@ package core
|
||||
import "context"
|
||||
|
||||
type key int
|
||||
|
||||
const paramsKey key = 0
|
||||
|
||||
func ParamsWith(ctx context.Context, params map[string]Value) context.Context {
|
||||
|
@ -16,9 +16,12 @@ func TestParamsWith(t *testing.T) {
|
||||
p["val2"] = values.NewString("test")
|
||||
|
||||
pc := core.ParamsWith(context.Background(), p)
|
||||
|
||||
So(pc, ShouldNotBeNil)
|
||||
So(pc.Value("params"), ShouldEqual, p)
|
||||
|
||||
out, err := core.ParamsFrom(pc)
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(out, ShouldEqual, p)
|
||||
})
|
||||
}
|
||||
|
||||
@ -36,10 +39,17 @@ func TestParamsFrom(t *testing.T) {
|
||||
pf, err := core.ParamsFrom(ctx)
|
||||
|
||||
So(err, ShouldNotBeNil)
|
||||
So(pf, ShouldBeNil)
|
||||
|
||||
ctx = context.WithValue(context.Background(), "params", p)
|
||||
pf, err = core.ParamsFrom(ctx)
|
||||
|
||||
So(err, ShouldNotBeNil)
|
||||
So(pf, ShouldBeNil)
|
||||
|
||||
ctx = core.ParamsWith(context.Background(), p)
|
||||
pf, err = core.ParamsFrom(ctx)
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
So(pf, ShouldEqual, p)
|
||||
})
|
||||
@ -60,7 +70,7 @@ func TestParamFrom(t *testing.T) {
|
||||
|
||||
So(err, ShouldNotBeNil)
|
||||
|
||||
ctx = context.WithValue(context.Background(), "params", p)
|
||||
ctx = core.ParamsWith(context.Background(), p)
|
||||
v, err := core.ParamFrom(ctx, "val1")
|
||||
|
||||
So(err, ShouldBeNil)
|
||||
|
Loading…
Reference in New Issue
Block a user