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

Unified Diff: common/clock/external_test.go

Issue 1679023005: Add Context cancellation to clock. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Actually upload the patch. Created 4 years, 10 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 | « common/clock/external.go ('k') | common/clock/systemclock.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/clock/external_test.go
diff --git a/common/clock/external_test.go b/common/clock/external_test.go
index 728bede333fc04c17944b1b0769dc72660daf9c3..ca81b90124bba5fa3b18cfacbfc53999ff677ab1 100644
--- a/common/clock/external_test.go
+++ b/common/clock/external_test.go
@@ -15,24 +15,24 @@ import (
// testClock is a Clock implementation used for testing.
type testClock struct {
nowCallback func() time.Time
- sleepCallback func()
+ sleepCallback func() error
newTimerCallback func() Timer
- afterCallback func() <-chan time.Time
+ afterCallback func() <-chan TimerResult
}
func (tc *testClock) Now() time.Time {
return tc.nowCallback()
}
-func (tc *testClock) Sleep(time.Duration) {
- tc.sleepCallback()
+func (tc *testClock) Sleep(context.Context, time.Duration) error {
+ return tc.sleepCallback()
}
-func (tc *testClock) NewTimer() Timer {
+func (tc *testClock) NewTimer(context.Context) Timer {
return tc.newTimerCallback()
}
-func (tc *testClock) After(time.Duration) <-chan time.Time {
+func (tc *testClock) After(context.Context, time.Duration) <-chan TimerResult {
return tc.afterCallback()
}
@@ -57,8 +57,9 @@ func TestExternal(t *testing.T) {
Convey(`Sleep() will use testClock's Sleep().`, func() {
used := false
- tc.sleepCallback = func() {
+ tc.sleepCallback = func() error {
used = true
+ return nil
}
Sleep(c, time.Second)
@@ -78,7 +79,7 @@ func TestExternal(t *testing.T) {
Convey(`After() will use testClock's After().`, func() {
used := false
- tc.afterCallback = func() <-chan time.Time {
+ tc.afterCallback = func() <-chan TimerResult {
used = true
return nil
}
« no previous file with comments | « common/clock/external.go ('k') | common/clock/systemclock.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698