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

Unified Diff: common/auth/internal/luci_ctx_test.go

Issue 2991193002: Clear LUCI_CONTEXT when running auth test. (Closed)
Patch Set: Clear LUCI_CONTEXT when running auth test. Created 3 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/auth/internal/luci_ctx_test.go
diff --git a/common/auth/internal/luci_ctx_test.go b/common/auth/internal/luci_ctx_test.go
index 4f76f74a56ed02d745e3e82ad57774d4fb6dc274..e7c0821c8ed819a0c36112a3b73857cd37d0a0ec 100644
--- a/common/auth/internal/luci_ctx_test.go
+++ b/common/auth/internal/luci_ctx_test.go
@@ -36,14 +36,20 @@ import (
func TestLUCIContextProvider(t *testing.T) {
t.Parallel()
+ // Clear any existing LUCI_CONTEXT["local_auth"], it may be present if the
+ // test runs on a LUCI bot.
+ baseCtx, err := lucictx.Set(context.Background(), "local_auth", nil)
+ if err != nil {
+ t.Fatal(err) // this should never happen
+ }
+
Convey("Requires local_auth", t, func() {
- _, err := NewLUCIContextTokenProvider(context.Background(), []string{"A"}, http.DefaultTransport)
+ _, err := NewLUCIContextTokenProvider(baseCtx, []string{"A"}, http.DefaultTransport)
So(err, ShouldErrLike, `no "local_auth" in LUCI_CONTEXT`)
})
Convey("Requires default_account_id", t, func() {
- ctx := context.Background()
- ctx = lucictx.SetLocalAuth(ctx, &lucictx.LocalAuth{
+ ctx := lucictx.SetLocalAuth(baseCtx, &lucictx.LocalAuth{
Accounts: []lucictx.LocalAuthAccount{{ID: "zzz"}},
})
_, err := NewLUCIContextTokenProvider(ctx, []string{"A"}, http.DefaultTransport)
@@ -82,8 +88,7 @@ func TestLUCIContextProvider(t *testing.T) {
}))
defer ts.Close()
- ctx := context.Background()
- ctx = lucictx.SetLocalAuth(ctx, &lucictx.LocalAuth{
+ ctx := lucictx.SetLocalAuth(baseCtx, &lucictx.LocalAuth{
RPCPort: uint32(ts.Listener.Addr().(*net.TCPAddr).Port),
Secret: []byte("zekret"),
DefaultAccountID: "acc_id",
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698