Skip to content
Prev Previous commit
Next Next commit
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.
  • Loading branch information
code-asher committed Oct 17, 2023
commit a0f22398d7776e6f83f1f4eb71f29cafce84d76a
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ data class WorkspaceAgentModel(
val agentID: UUID?,
val workspaceID: UUID,
val workspaceName: String,
val name: String, // Name of the workspace OR the agent if this is for an agent.
val name: String, // Name of the workspace OR workspace.agent if this is for an agent.
val templateID: UUID,
val templateName: String,
val templateIconPath: String,
Expand Down
15 changes: 11 additions & 4 deletions src/test/groovy/DataGen.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,19 @@ import com.coder.gateway.sdk.v2.models.WorkspaceStatus
import com.coder.gateway.sdk.v2.models.WorkspaceTransition

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