mirror of
https://github.com/coder/coder.git
synced 2025-07-09 11:45:56 +00:00
feat: add has-ai-task filters to the /workspaces and /templates endpoints (#18387)
This PR allows filtering templates and workspaces with the `has-ai-task` filter as described in the [Coder Tasks RFC](https://www.notion.so/coderhq/Coder-Tasks-207d579be5928053ab68c8d9a4b59eaa?source=copy_link#20ad579be59280e6a000eb0646d3c2df).
This commit is contained in:
@ -222,6 +222,36 @@ func TestSearchWorkspace(t *testing.T) {
|
||||
OrganizationID: uuid.MustParse("08eb6715-02f8-45c5-b86d-03786fcfbb4e"),
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "HasAITaskTrue",
|
||||
Query: "has-ai-task:true",
|
||||
Expected: database.GetWorkspacesParams{
|
||||
HasAITask: sql.NullBool{
|
||||
Bool: true,
|
||||
Valid: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "HasAITaskFalse",
|
||||
Query: "has-ai-task:false",
|
||||
Expected: database.GetWorkspacesParams{
|
||||
HasAITask: sql.NullBool{
|
||||
Bool: false,
|
||||
Valid: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "HasAITaskMissing",
|
||||
Query: "",
|
||||
Expected: database.GetWorkspacesParams{
|
||||
HasAITask: sql.NullBool{
|
||||
Bool: false,
|
||||
Valid: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// Failures
|
||||
{
|
||||
@ -559,6 +589,36 @@ func TestSearchTemplates(t *testing.T) {
|
||||
FuzzyName: "foobar",
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "HasAITaskTrue",
|
||||
Query: "has-ai-task:true",
|
||||
Expected: database.GetTemplatesWithFilterParams{
|
||||
HasAITask: sql.NullBool{
|
||||
Bool: true,
|
||||
Valid: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "HasAITaskFalse",
|
||||
Query: "has-ai-task:false",
|
||||
Expected: database.GetTemplatesWithFilterParams{
|
||||
HasAITask: sql.NullBool{
|
||||
Bool: false,
|
||||
Valid: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "HasAITaskMissing",
|
||||
Query: "",
|
||||
Expected: database.GetTemplatesWithFilterParams{
|
||||
HasAITask: sql.NullBool{
|
||||
Bool: false,
|
||||
Valid: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
|
Reference in New Issue
Block a user