| 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.AppID(c), ShouldEqual, "app-id") | 21 So(info.AppID(c), ShouldEqual, "app-id") |
| 22 So(info.FullyQualifiedAppID(c), ShouldEqual, "dev~app-id") | 22 So(info.FullyQualifiedAppID(c), ShouldEqual, "dev~app-id") |
| 23 So(info.RequestID(c), ShouldEqual, "test-request-id") | 23 So(info.RequestID(c), ShouldEqual, "test-request-id") |
| 24 sa, err := info.ServiceAccount(c) |
| 25 So(err, ShouldBeNil) |
| 26 So(sa, ShouldEqual, "user@example.com") |
| 24 | 27 |
| 25 // Setting to "override" applies to initial context. | 28 // Setting to "override" applies to initial context. |
| 26 c = info.GetTestable(c).SetRequestID("override") | 29 c = info.GetTestable(c).SetRequestID("override") |
| 27 So(info.RequestID(c), ShouldEqual, "override") | 30 So(info.RequestID(c), ShouldEqual, "override") |
| 28 | 31 |
| 29 // Derive inner context, "override" applies. | 32 // Derive inner context, "override" applies. |
| 30 c = info.MustNamespace(c, "valid_namespace_name") | 33 c = info.MustNamespace(c, "valid_namespace_name") |
| 31 So(info.RequestID(c), ShouldEqual, "override") | 34 So(info.RequestID(c), ShouldEqual, "override") |
| 32 }) | 35 }) |
| 33 } | 36 } |
| OLD | NEW |