- Notifications
You must be signed in to change notification settings - Fork928
fix: derive running ws stop time from deadline#1920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
a72b187
24ccaee
0f72a6d
c5c5f4f
11fe7f2
538bbe8
5e6472d
d0a9656
df54df0
f825f2d
6a48ea6
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as TypesGen from "../api/typesGenerated" | ||
import * as Mocks from "../testHelpers/entities" | ||
import { isWorkspaceOn } from "./workspace" | ||
describe("util > workspace", () => { | ||
describe("isWorkspaceOn", () => { | ||
it.each<[TypesGen.WorkspaceTransition, TypesGen.ProvisionerJobStatus, boolean]>([ | ||
["delete", "canceled", false], | ||
["delete", "canceling", false], | ||
["delete", "failed", false], | ||
["delete", "pending", false], | ||
["delete", "running", false], | ||
["delete", "succeeded", false], | ||
["stop", "canceled", false], | ||
["stop", "canceling", false], | ||
["stop", "failed", false], | ||
["stop", "pending", false], | ||
["stop", "running", false], | ||
["stop", "succeeded", false], | ||
["start", "canceled", false], | ||
["start", "canceling", false], | ||
["start", "failed", false], | ||
["start", "pending", false], | ||
["start", "running", false], | ||
["start", "succeeded", true], | ||
Comment on lines +8 to +27 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. 💝 | ||
])(`transition=%p, status=%p, isWorkspaceOn=%p`, (transition, status, isOn) => { | ||
const workspace: TypesGen.Workspace = { | ||
...Mocks.MockWorkspace, | ||
latest_build: { | ||
...Mocks.MockWorkspaceBuild, | ||
job: { | ||
...Mocks.MockProvisionerJob, | ||
status, | ||
}, | ||
transition, | ||
}, | ||
} | ||
expect(isWorkspaceOn(workspace)).toBe(isOn) | ||
}) | ||
}) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { Theme } from "@material-ui/core/styles" | ||
import dayjs from "dayjs" | ||
import { WorkspaceBuildTransition } from "../api/types" | ||
import {Workspace,WorkspaceAgent, WorkspaceBuild } from "../api/typesGenerated" | ||
export type WorkspaceStatus = | ||
| "queued" | ||
@@ -185,3 +185,9 @@ export const getDisplayAgentStatus = ( | ||
} | ||
} | ||
} | ||
export const isWorkspaceOn = (workspace: Workspace): boolean => { | ||
const transition = workspace.latest_build.transition | ||
const status = workspace.latest_build.job.status | ||
return transition === "start" && status === "succeeded" | ||
} | ||
Comment on lines +189 to +193 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. 👍 it's a narrow definition of 'on' but I think that's the correct one. |