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

Unified Diff: scheduler/appengine/presentation/state_test.go

Issue 2945843002: scheduler WIP: add GetAllJobs api. (Closed)
Patch Set: update test Created 3 years, 6 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: scheduler/appengine/presentation/state_test.go
diff --git a/scheduler/appengine/presentation/state_test.go b/scheduler/appengine/presentation/state_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..f170b21e6345d1b79d42e039ebad97ebdf11708d
--- /dev/null
+++ b/scheduler/appengine/presentation/state_test.go
@@ -0,0 +1,43 @@
+// Copyright 2017 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 presentation
+
+import (
+ "testing"
+
+ "github.com/luci/luci-go/scheduler/appengine/engine"
+ "github.com/luci/luci-go/scheduler/appengine/task"
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestGetPublicStateKind(t *testing.T) {
+ t.Parallel()
+
+ Convey("works", t, func() {
+ So(GetPublicStateKind(&engine.Job{
+ State: engine.JobState{State: engine.JobStateOverrun},
+ }, task.Traits{}), ShouldEqual, PublicStateOverrun)
+
+ So(GetPublicStateKind(&engine.Job{
+ State: engine.JobState{State: engine.JobStateSlowQueue},
+ }, task.Traits{}), ShouldEqual, PublicStateStarting)
+
+ So(GetPublicStateKind(&engine.Job{
+ State: engine.JobState{State: engine.JobStateSlowQueue, InvocationRetryCount: 1},
+ }, task.Traits{}), ShouldEqual, PublicStateRetrying)
+
+ So(GetPublicStateKind(&engine.Job{
+ Paused: true,
+ State: engine.JobState{State: engine.JobStateSuspended},
+ }, task.Traits{}), ShouldEqual, PublicStatePaused)
+
+ So(GetPublicStateKind(&engine.Job{
+ State: engine.JobState{State: engine.JobStateQueued, InvocationID: 1},
+ }, task.Traits{Multistage: true}), ShouldEqual, PublicStateStarting)
+ So(GetPublicStateKind(&engine.Job{
Vadim Sh. 2017/06/20 17:48:54 nit: \n :)
tandrii(chromium) 2017/06/20 19:48:36 Done.
+ State: engine.JobState{State: engine.JobStateQueued, InvocationID: 1},
+ }, task.Traits{Multistage: false}), ShouldEqual, PublicStateRunning)
+ })
+}

Powered by Google App Engine
This is Rietveld 408576698