-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: derive running ws stop time from deadline (#1920)
* refactor: isWorkspaceOn utility Summary: A utility is function is added that answers the question if a workspace is on. Impact: This is a shared piece of logic in workspace scheduling presentations. In particular it unblocks work in 1779, or at least allows an implementation that shares details with the WorkspaceScheduleBanner. Notes: We could possibly instead return whether the workspace is "ON", "UNKNOWN", or "OFF". Maybe a future improvement for that could be made as the neds arrises. * fix: derive running ws stop time from deadline Summary: When a workspace is on, the remaining time until shutdown needs to be derived from the deadline timestamp, not implied from the TTL
- Loading branch information
1 parent
c6167a9
commit 56ec53d
Showing
8 changed files
with
164 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | ||
])(`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) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters