MCPcopy Index your code
hub / github.com/coder/coder / getTemplateByID

Function getTemplateByID

enterprise/coderd/notifications_test.go:142–162  ·  view source on GitHub ↗

nolint:revive // t takes precedence.

(t *testing.T, ctx context.Context, api *codersdk.Client, id uuid.UUID)

Source from the content-addressed store, hash-verified

140
141// nolint:revive // t takes precedence.
142func getTemplateByID(t *testing.T, ctx context.Context, api *codersdk.Client, id uuid.UUID) (*codersdk.NotificationTemplate, error) {
143 t.Helper()
144
145 var template codersdk.NotificationTemplate
146 templates, err := api.GetSystemNotificationTemplates(ctx)
147 if err != nil {
148 return nil, err
149 }
150
151 for _, tmpl := range templates {
152 if tmpl.ID == id {
153 template = tmpl
154 }
155 }
156
157 if template.ID == uuid.Nil {
158 return nil, xerrors.Errorf("template not found: %q", id.String())
159 }
160
161 return &template, nil
162}

Callers 1

Calls 4

HelperMethod · 0.65
ErrorfMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected