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

Side by Side Diff: tokenserver/appengine/impl/certconfig/ca_test.go

Issue 2779323002: token-server: Warmup some local caches in /_ah/warmup. (Closed)
Patch Set: also warmup delegation config Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 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 certconfig 5 package certconfig
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 "time" 9 "time"
10 10
11 ds "github.com/luci/gae/service/datastore"
12
11 "github.com/luci/luci-go/appengine/gaetesting" 13 "github.com/luci/luci-go/appengine/gaetesting"
12 "github.com/luci/luci-go/common/clock/testclock" 14 "github.com/luci/luci-go/common/clock/testclock"
13 "github.com/luci/luci-go/common/data/caching/proccache" 15 "github.com/luci/luci-go/common/data/caching/proccache"
14 16
15 . "github.com/smartystreets/goconvey/convey" 17 . "github.com/smartystreets/goconvey/convey"
16 ) 18 )
17 19
20 func TestListCAs(t *testing.T) {
21 Convey("ListCAs works", t, func() {
22 ctx := gaetesting.TestingContext()
23
24 // Empty.
25 cas, err := ListCAs(ctx)
26 So(err, ShouldBeNil)
27 So(len(cas), ShouldEqual, 0)
28
29 // Add some.
30 err = ds.Put(ctx, &CA{CN: "abc", Removed: true}, &CA{CN: "def"})
31 So(err, ShouldBeNil)
32 ds.GetTestable(ctx).CatchupIndexes()
33
34 cas, err = ListCAs(ctx)
35 So(err, ShouldBeNil)
36 So(cas, ShouldResemble, []string{"def"})
37 })
38 }
39
18 func TestCAUniqueIDToCNMapLoadStore(t *testing.T) { 40 func TestCAUniqueIDToCNMapLoadStore(t *testing.T) {
19 Convey("CAUniqueIDToCNMap Load and Store works", t, func() { 41 Convey("CAUniqueIDToCNMap Load and Store works", t, func() {
20 ctx := gaetesting.TestingContext() 42 ctx := gaetesting.TestingContext()
21 43
22 // Empty. 44 // Empty.
23 mapping, err := LoadCAUniqueIDToCNMap(ctx) 45 mapping, err := LoadCAUniqueIDToCNMap(ctx)
24 So(err, ShouldEqual, nil) 46 So(err, ShouldEqual, nil)
25 So(len(mapping), ShouldEqual, 0) 47 So(len(mapping), ShouldEqual, 0)
26 48
27 // Store some. 49 // Store some.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 So(err, ShouldBeNil) 84 So(err, ShouldBeNil)
63 So(val, ShouldEqual, "") 85 So(val, ShouldEqual, "")
64 86
65 // Updated after cache expires. 87 // Updated after cache expires.
66 clk.Add(2 * time.Minute) 88 clk.Add(2 * time.Minute)
67 val, err = GetCAByUniqueID(ctx, 1) 89 val, err = GetCAByUniqueID(ctx, 1)
68 So(err, ShouldBeNil) 90 So(err, ShouldBeNil)
69 So(val, ShouldEqual, "abc") 91 So(val, ShouldEqual, "abc")
70 }) 92 })
71 } 93 }
OLDNEW
« no previous file with comments | « tokenserver/appengine/impl/certconfig/ca.go ('k') | tokenserver/appengine/impl/certconfig/rpc_list_cas.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698