This test just validates that the CLI command accepts its known arguments.
(t *testing.T)
| 188 | |
| 189 | // This test just validates that the CLI command accepts its known arguments. |
| 190 | func TestScaleTestDashboard(t *testing.T) { |
| 191 | t.Parallel() |
| 192 | if testutil.RaceEnabled() { |
| 193 | t.Skip("Skipping due to race detector") |
| 194 | } |
| 195 | |
| 196 | t.Run("MinWait", func(t *testing.T) { |
| 197 | t.Parallel() |
| 198 | ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitShort) |
| 199 | defer cancelFunc() |
| 200 | |
| 201 | log := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}) |
| 202 | client := coderdtest.New(t, &coderdtest.Options{ |
| 203 | Logger: &log, |
| 204 | }) |
| 205 | _ = coderdtest.CreateFirstUser(t, client) |
| 206 | |
| 207 | inv, root := clitest.New(t, "exp", "scaletest", "dashboard", |
| 208 | "--interval", "0s", |
| 209 | ) |
| 210 | clitest.SetupConfig(t, client, root) |
| 211 | pty := ptytest.New(t) |
| 212 | inv.Stdout = pty.Output() |
| 213 | inv.Stderr = pty.Output() |
| 214 | |
| 215 | err := inv.WithContext(ctx).Run() |
| 216 | require.ErrorContains(t, err, "--interval must be greater than zero") |
| 217 | }) |
| 218 | |
| 219 | t.Run("MaxWait", func(t *testing.T) { |
| 220 | t.Parallel() |
| 221 | ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitShort) |
| 222 | defer cancelFunc() |
| 223 | |
| 224 | log := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}) |
| 225 | client := coderdtest.New(t, &coderdtest.Options{ |
| 226 | Logger: &log, |
| 227 | }) |
| 228 | _ = coderdtest.CreateFirstUser(t, client) |
| 229 | |
| 230 | inv, root := clitest.New(t, "exp", "scaletest", "dashboard", |
| 231 | "--interval", "1s", |
| 232 | "--jitter", "1s", |
| 233 | ) |
| 234 | clitest.SetupConfig(t, client, root) |
| 235 | pty := ptytest.New(t) |
| 236 | inv.Stdout = pty.Output() |
| 237 | inv.Stderr = pty.Output() |
| 238 | |
| 239 | err := inv.WithContext(ctx).Run() |
| 240 | require.ErrorContains(t, err, "--jitter must be less than --interval") |
| 241 | }) |
| 242 | |
| 243 | t.Run("OK", func(t *testing.T) { |
| 244 | t.Parallel() |
| 245 | ctx, cancelFunc := context.WithTimeout(context.Background(), testutil.WaitMedium) |
| 246 | defer cancelFunc() |
| 247 |
nothing calls this directly
no test coverage detected