(t *testing.T)
| 206 | } |
| 207 | |
| 208 | func 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 | } |
nothing calls this directly
no test coverage detected