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

Function TestUserSecretValueValid

codersdk/usersecretvalidation_test.go:208–236  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

206}
207
208func TestUserSecretValueValid(t *testing.T) {
209 t.Parallel()
210
211 tests := []struct {
212 name string
213 input string
214 wantErr bool
215 }{
216 {name: "NormalString", input: "my-secret-token"},
217 {name: "Empty", input: ""},
218 {name: "WithNewlines", input: "line1\nline2\nline3"},
219 {name: "WithTabs", input: "key\tvalue"},
220 {name: "NullByte", input: "before\x00after", wantErr: true},
221 {name: "ExactlyAtLimit", input: strings.Repeat("a", codersdk.MaxUserSecretValueBytes)},
222 {name: "OverLimit", input: strings.Repeat("a", codersdk.MaxUserSecretValueBytes+1), wantErr: true},
223 }
224
225 for _, tt := range tests {
226 t.Run(tt.name, func(t *testing.T) {
227 t.Parallel()
228 err := codersdk.UserSecretValueValid(tt.input)
229 if tt.wantErr {
230 assert.Error(t, err)
231 } else {
232 assert.NoError(t, err)
233 }
234 })
235 }
236}

Callers

nothing calls this directly

Calls 3

UserSecretValueValidFunction · 0.92
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected