diff --git a/coderd/templates.go b/coderd/templates.go index e43fdb61e007a..4fc47288ff6c5 100644 --- a/coderd/templates.go +++ b/coderd/templates.go @@ -470,9 +470,6 @@ func (api *API) patchTemplateMeta(rw http.ResponseWriter, r *http.Request) { if desc == "" { desc = template.Description } - if icon == "" { - icon = template.Icon - } if minAutostartInterval == 0 { minAutostartInterval = time.Duration(template.MinAutostartInterval) } diff --git a/coderd/templates_test.go b/coderd/templates_test.go index ba01d3f3d5739..b05dd25024f92 100644 --- a/coderd/templates_test.go +++ b/coderd/templates_test.go @@ -481,6 +481,27 @@ func TestPatchTemplateMeta(t *testing.T) { assert.Equal(t, template.MaxTTLMillis, updated.MaxTTLMillis) assert.Equal(t, template.MinAutostartIntervalMillis, updated.MinAutostartIntervalMillis) }) + + t.Run("RemoveIcon", func(t *testing.T) { + t.Parallel() + + client := coderdtest.New(t, nil) + user := coderdtest.CreateFirstUser(t, client) + version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil) + template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID, func(ctr *codersdk.CreateTemplateRequest) { + ctr.Icon = "/icons/code.png" + }) + req := codersdk.UpdateTemplateMeta{ + Icon: "", + } + + ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) + defer cancel() + + updated, err := client.UpdateTemplateMeta(ctx, template.ID, req) + require.NoError(t, err) + assert.Equal(t, updated.Icon, "") + }) } func TestDeleteTemplate(t *testing.T) {