OLD | NEW |
1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package memory | 5 package memory |
6 | 6 |
7 import ( | 7 import ( |
8 "testing" | 8 "testing" |
9 | 9 |
10 "github.com/luci/gae/service/info" | 10 "github.com/luci/gae/service/info" |
11 "golang.org/x/net/context" | 11 "golang.org/x/net/context" |
12 | 12 |
13 . "github.com/smartystreets/goconvey/convey" | 13 . "github.com/smartystreets/goconvey/convey" |
14 ) | 14 ) |
15 | 15 |
16 func TestMustNamespace(t *testing.T) { | 16 func TestMustNamespace(t *testing.T) { |
17 Convey("Testable interface works", t, func() { | 17 Convey("Testable interface works", t, func() { |
18 c := UseWithAppID(context.Background(), "dev~app-id") | 18 c := UseWithAppID(context.Background(), "dev~app-id") |
19 | 19 |
20 // Default value. | 20 // Default value. |
21 » » So(info.Get(c).AppID(), ShouldEqual, "app-id") | 21 » » So(info.AppID(c), ShouldEqual, "app-id") |
22 » » So(info.Get(c).FullyQualifiedAppID(), ShouldEqual, "dev~app-id") | 22 » » So(info.FullyQualifiedAppID(c), ShouldEqual, "dev~app-id") |
23 » » So(info.Get(c).RequestID(), ShouldEqual, "test-request-id") | 23 » » So(info.RequestID(c), ShouldEqual, "test-request-id") |
24 | 24 |
25 // Setting to "override" applies to initial context. | 25 // Setting to "override" applies to initial context. |
26 » » c = info.Get(c).Testable().SetRequestID("override") | 26 » » c = info.GetTestable(c).SetRequestID("override") |
27 » » So(info.Get(c).RequestID(), ShouldEqual, "override") | 27 » » So(info.RequestID(c), ShouldEqual, "override") |
28 | 28 |
29 // Derive inner context, "override" applies. | 29 // Derive inner context, "override" applies. |
30 » » c = info.Get(c).MustNamespace("valid_namespace_name") | 30 » » c = info.MustNamespace(c, "valid_namespace_name") |
31 » » So(info.Get(c).RequestID(), ShouldEqual, "override") | 31 » » So(info.RequestID(c), ShouldEqual, "override") |
32 }) | 32 }) |
33 } | 33 } |
OLD | NEW |