Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: impl/cloud/info_test.go

Issue 2302743002: Interface update, per-method Contexts. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: impl/cloud/info_test.go
diff --git a/impl/cloud/info_test.go b/impl/cloud/info_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..f2f90b4ec0f1f65e6dcfa83e09147b8951c96f6f
--- /dev/null
+++ b/impl/cloud/info_test.go
@@ -0,0 +1,55 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package cloud
+
+import (
+ "fmt"
+ "strings"
+ "testing"
+
+ "github.com/luci/gae/service/info"
+
+ "golang.org/x/net/context"
+
+ . "github.com/luci/luci-go/common/testing/assertions"
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestInfo(t *testing.T) {
+ t.Parallel()
+
+ Convey(`A testing Info service`, t, func() {
+ const maxNamespaceLen = 100
+
+ c := useInfo(context.Background())
+
+ Convey(`Can set valid namespaces.`, func() {
+ for _, v := range []string{
+ "",
+ "test",
+ "0123456789-ABCDEFGHIJKLMNOPQRSTUVWXYZ.abcdefghijklmnopqrstuvwxyz_",
+ strings.Repeat("X", maxNamespaceLen),
+ } {
+ Convey(fmt.Sprintf(`Rejects %q`, v), func() {
+ c, err := info.Namespace(c, v)
+ So(err, ShouldBeNil)
+ So(info.GetNamespace(c), ShouldEqual, v)
+ })
+ }
+ })
+
+ Convey(`Rejects invalid namespaces on the client.`, func() {
+ for _, v := range []string{
+ " ",
+ strings.Repeat("X", maxNamespaceLen+1),
+ } {
+ Convey(fmt.Sprintf(`Rejects %q`, v), func() {
+ _, err := info.Namespace(c, v)
+ So(err, ShouldErrLike, "does not match")
+ })
+ }
+ })
+ })
+}

Powered by Google App Engine
This is Rietveld 408576698