feat(coderd): use task data model for list (#20394)

Updates coder/internal#976
This commit is contained in:
Mathias Fredriksson
2025-10-23 20:22:51 +03:00
committed by GitHub
parent 2c6cbf15e2
commit a106d67c07
28 changed files with 985 additions and 622 deletions
+13 -15
View File
@@ -22,17 +22,15 @@ import (
func Test_TaskSend(t *testing.T) {
t.Parallel()
t.Skip("TODO(mafredri): Remove, fixed up-stack!")
t.Run("ByWorkspaceName_WithArgument", func(t *testing.T) {
t.Run("ByTaskName_WithArgument", func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong)
client, workspace := setupCLITaskTest(ctx, t, fakeAgentAPITaskSendOK(t, "carry on with the task", "you got it"))
client, task := setupCLITaskTest(ctx, t, fakeAgentAPITaskSendOK(t, "carry on with the task", "you got it"))
userClient := client
var stdout strings.Builder
inv, root := clitest.New(t, "exp", "task", "send", workspace.Name, "carry on with the task")
inv, root := clitest.New(t, "exp", "task", "send", task.Name, "carry on with the task")
inv.Stdout = &stdout
clitest.SetupConfig(t, userClient, root)
@@ -40,15 +38,15 @@ func Test_TaskSend(t *testing.T) {
require.NoError(t, err)
})
t.Run("ByWorkspaceID_WithArgument", func(t *testing.T) {
t.Run("ByTaskID_WithArgument", func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong)
client, workspace := setupCLITaskTest(ctx, t, fakeAgentAPITaskSendOK(t, "carry on with the task", "you got it"))
client, task := setupCLITaskTest(ctx, t, fakeAgentAPITaskSendOK(t, "carry on with the task", "you got it"))
userClient := client
var stdout strings.Builder
inv, root := clitest.New(t, "exp", "task", "send", workspace.ID.String(), "carry on with the task")
inv, root := clitest.New(t, "exp", "task", "send", task.ID.String(), "carry on with the task")
inv.Stdout = &stdout
clitest.SetupConfig(t, userClient, root)
@@ -56,15 +54,15 @@ func Test_TaskSend(t *testing.T) {
require.NoError(t, err)
})
t.Run("ByWorkspaceName_WithStdin", func(t *testing.T) {
t.Run("ByTaskName_WithStdin", func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong)
client, workspace := setupCLITaskTest(ctx, t, fakeAgentAPITaskSendOK(t, "carry on with the task", "you got it"))
client, task := setupCLITaskTest(ctx, t, fakeAgentAPITaskSendOK(t, "carry on with the task", "you got it"))
userClient := client
var stdout strings.Builder
inv, root := clitest.New(t, "exp", "task", "send", workspace.Name, "--stdin")
inv, root := clitest.New(t, "exp", "task", "send", task.Name, "--stdin")
inv.Stdout = &stdout
inv.Stdin = strings.NewReader("carry on with the task")
clitest.SetupConfig(t, userClient, root)
@@ -73,7 +71,7 @@ func Test_TaskSend(t *testing.T) {
require.NoError(t, err)
})
t.Run("WorkspaceNotFound_ByName", func(t *testing.T) {
t.Run("TaskNotFound_ByName", func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong)
@@ -91,7 +89,7 @@ func Test_TaskSend(t *testing.T) {
require.ErrorContains(t, err, httpapi.ResourceNotFoundResponse.Message)
})
t.Run("WorkspaceNotFound_ByID", func(t *testing.T) {
t.Run("TaskNotFound_ByID", func(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong)
@@ -113,10 +111,10 @@ func Test_TaskSend(t *testing.T) {
t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong)
userClient, workspace := setupCLITaskTest(ctx, t, fakeAgentAPITaskSendErr(t, assert.AnError))
userClient, task := setupCLITaskTest(ctx, t, fakeAgentAPITaskSendErr(t, assert.AnError))
var stdout strings.Builder
inv, root := clitest.New(t, "exp", "task", "send", workspace.Name, "some task input")
inv, root := clitest.New(t, "exp", "task", "send", task.Name, "some task input")
inv.Stdout = &stdout
clitest.SetupConfig(t, userClient, root)