OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package coordinator | 5 package coordinator |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "testing" | 9 "testing" |
10 "time" | 10 "time" |
11 | 11 |
12 "github.com/luci/gae/impl/memory" | 12 "github.com/luci/gae/impl/memory" |
13 ds "github.com/luci/gae/service/datastore" | 13 ds "github.com/luci/gae/service/datastore" |
14 "github.com/luci/luci-go/common/clock/testclock" | 14 "github.com/luci/luci-go/common/clock/testclock" |
15 "github.com/luci/luci-go/common/logdog/types" | 15 "github.com/luci/luci-go/common/logdog/types" |
16 "golang.org/x/net/context" | 16 "golang.org/x/net/context" |
17 | 17 |
18 . "github.com/luci/luci-go/common/testing/assertions" | 18 . "github.com/luci/luci-go/common/testing/assertions" |
19 . "github.com/smartystreets/goconvey/convey" | 19 . "github.com/smartystreets/goconvey/convey" |
20 ) | 20 ) |
21 | 21 |
22 func TestLogStreamState(t *testing.T) { | 22 func TestLogStreamState(t *testing.T) { |
23 t.Parallel() | 23 t.Parallel() |
24 | 24 |
25 Convey(`A testing log stream state`, t, func() { | 25 Convey(`A testing log stream state`, t, func() { |
26 c, tc := testclock.UseTime(context.Background(), testclock.TestT
imeLocal) | 26 c, tc := testclock.UseTime(context.Background(), testclock.TestT
imeLocal) |
27 c = memory.Use(c) | 27 c = memory.Use(c) |
28 | 28 |
29 » » if err := WithProjectNamespaceNoAuth(&c, "proj-foo"); err != nil
{ | 29 » » if err := WithProjectNamespace(&c, "proj-foo", NamespaceAccessNo
Auth); err != nil { |
30 panic(err) | 30 panic(err) |
31 } | 31 } |
32 di := ds.Get(c) | 32 di := ds.Get(c) |
33 di.Testable().Consistent(true) | 33 di.Testable().Consistent(true) |
34 | 34 |
35 now := ds.RoundTime(tc.Now().UTC()) | 35 now := ds.RoundTime(tc.Now().UTC()) |
36 ls := LogStream{ID: LogStreamID("testing/+/log/stream")} | 36 ls := LogStream{ID: LogStreamID("testing/+/log/stream")} |
37 lst := ls.State(di) | 37 lst := ls.State(di) |
38 | 38 |
39 lst.Schema = CurrentSchemaVersion | 39 lst.Schema = CurrentSchemaVersion |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 lst.ArchivedTime = now | 115 lst.ArchivedTime = now |
116 So(di.Put(lst), ShouldBeNil) | 116 So(di.Put(lst), ShouldBeNil) |
117 | 117 |
118 So(runQuery(q.Eq("_Terminated", true)),
ShouldBeTrue) | 118 So(runQuery(q.Eq("_Terminated", true)),
ShouldBeTrue) |
119 So(runQuery(q.Eq("_ArchivalState", Archi
vedComplete)), ShouldBeTrue) | 119 So(runQuery(q.Eq("_ArchivalState", Archi
vedComplete)), ShouldBeTrue) |
120 }) | 120 }) |
121 }) | 121 }) |
122 }) | 122 }) |
123 }) | 123 }) |
124 } | 124 } |
OLD | NEW |