Skip to content

Commit 1accf42

Browse files
fix: tests
fix: maybe fix? does this fix it?
1 parent 414465b commit 1accf42

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

docs/resources/ai_task.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Use this resource to define Coder tasks.
2222

2323
### Read-Only
2424

25+
- `enabled` (Boolean) The field is true if the template is being provisioned as a task.
2526
- `id` (String) A unique identifier for this resource.
2627
- `prompt` (String) The prompt text provided to the task by Coder.
2728

integration/coder-ai-task/main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ resource "coder_ai_task" "task" {
4141
locals {
4242
# NOTE: these must all be strings in the output
4343
output = {
44-
"ai_task.id" = coder_ai_task.task.id
45-
"ai_task.app_id" = coder_ai_task.task.app_id
46-
"ai_task.prompt" = coder_ai_task.task.prompt
47-
"app.id" = coder_app.ai_interface.id
44+
"ai_task.id" = coder_ai_task.task.id
45+
"ai_task.app_id" = coder_ai_task.task.app_id
46+
"ai_task.prompt" = coder_ai_task.task.prompt
47+
"ai_task.enabled" = tostring(coder_ai_task.task.enabled)
48+
"app.id" = coder_app.ai_interface.id
4849
}
4950
}
5051

integration/integration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ func TestIntegration(t *testing.T) {
219219
"ai_task.prompt": "",
220220
"ai_task.app_id": `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,
221221
"app.id": `^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`,
222+
"ai_task.enabled": strconv.FormatBool(os.Getenv("CODER_TASK_ID") != ""),
222223
},
223224
},
224225
} {

provider/ai_task.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func aiTaskResource() *schema.Resource {
3232
CreateContext: func(c context.Context, resourceData *schema.ResourceData, i any) diag.Diagnostics {
3333
var diags diag.Diagnostics
3434

35-
if idStr := os.Getenv("CODER_TASK_ID"); idStr != "" {
36-
resourceData.SetId(idStr)
35+
if id, err := uuid.Parse(os.Getenv("CODER_TASK_ID")); err == nil && id != uuid.Nil {
36+
resourceData.SetId(id.String())
3737
resourceData.Set("enabled", true)
3838
} else {
3939
resourceData.SetId(uuid.NewString())

0 commit comments

Comments
 (0)