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

Function TestGetUserSecrets

coderd/usersecrets_test.go:210–244  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

208}
209
210func TestGetUserSecrets(t *testing.T) {
211 t.Parallel()
212 client := coderdtest.New(t, nil)
213 _ = coderdtest.CreateFirstUser(t, client)
214
215 // Verify no secrets exist on a fresh user.
216 ctx := testutil.Context(t, testutil.WaitMedium)
217 secrets, err := client.UserSecrets(ctx, codersdk.Me)
218 require.NoError(t, err)
219 assert.Empty(t, secrets)
220
221 t.Run("WithSecrets", func(t *testing.T) {
222 t.Parallel()
223 ctx := testutil.Context(t, testutil.WaitMedium)
224
225 _, err := client.CreateUserSecret(ctx, codersdk.Me, codersdk.CreateUserSecretRequest{
226 Name: "list-secret-a",
227 Value: "value-a",
228 })
229 require.NoError(t, err)
230
231 _, err = client.CreateUserSecret(ctx, codersdk.Me, codersdk.CreateUserSecretRequest{
232 Name: "list-secret-b",
233 Value: "value-b",
234 })
235 require.NoError(t, err)
236
237 secrets, err := client.UserSecrets(ctx, codersdk.Me)
238 require.NoError(t, err)
239 require.Len(t, secrets, 2)
240 // Sorted by name.
241 assert.Equal(t, "list-secret-a", secrets[0].Name)
242 assert.Equal(t, "list-secret-b", secrets[1].Name)
243 })
244}
245
246func TestGetUserSecret(t *testing.T) {
247 t.Parallel()

Callers

nothing calls this directly

Calls 9

NewFunction · 0.92
CreateFirstUserFunction · 0.92
ContextFunction · 0.92
UserSecretsMethod · 0.80
RunMethod · 0.65
CreateUserSecretMethod · 0.65
EmptyMethod · 0.45
LenMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected