Skip to content

Commit b69d8fa

Browse files
committed
Fix DataGen not quite mirroring toAgentModels()
It should omit agent information when the workspace specifies no agents and the name should combine the workspace and agent names.
1 parent c8e503e commit b69d8fa

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/main/kotlin/com/coder/gateway/models/WorkspaceAgentModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ data class WorkspaceAgentModel(
1717
val agentID: UUID?,
1818
val workspaceID: UUID,
1919
val workspaceName: String,
20-
val name: String, // Name of the workspace OR the agent if this is for an agent.
20+
val name: String, // Name of the workspace OR workspace.agent if this is for an agent.
2121
val templateID: UUID,
2222
val templateName: String,
2323
val templateIconPath: String,

src/test/groovy/DataGen.groovy

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ import com.coder.gateway.sdk.v2.models.WorkspaceStatus
55
import com.coder.gateway.sdk.v2.models.WorkspaceTransition
66

77
class DataGen {
8-
static WorkspaceAgentModel workspace(String name, String workspaceName = name) {
8+
// Create a random workspace agent model. If the workspace name is omitted
9+
// then return a model without any agent bits, similar to what
10+
// toAgentModels() does if the workspace does not specify any agents.
11+
// TODO: Maybe better to randomly generate the workspace and then call
12+
// toAgentModels() on it. Also the way an "agent" model can have no
13+
// agent in it seems weird; can we refactor to remove
14+
// WorkspaceAgentModel and use the original structs from the API?
15+
static WorkspaceAgentModel workspace(String name, String workspaceName = "", UUID agentId = UUID.randomUUID()) {
916
return new WorkspaceAgentModel(
17+
workspaceName == "" ? null : agentId,
1018
UUID.randomUUID(),
11-
UUID.randomUUID(),
12-
workspaceName,
13-
name,
19+
workspaceName == "" ? name : workspaceName,
20+
workspaceName == "" ? name : (workspaceName + "." + name),
1421
UUID.randomUUID(),
1522
"template-name",
1623
"template-icon-path",

0 commit comments

Comments
 (0)