Skip to content

Commit 017c57e

Browse files
committed
add random ext to screenshots
1 parent 47b4bfc commit 017c57e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scaletest/dashboard/chromedp.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
"github.com/chromedp/chromedp"
1414
"golang.org/x/xerrors"
1515

16+
"github.com/coder/coder/v2/cryptorand"
17+
1618
"cdr.dev/slog"
1719
)
1820

@@ -235,7 +237,12 @@ func Screenshot(ctx context.Context, name string) (string, error) {
235237
if err := chromedp.Run(ctx, chromedp.CaptureScreenshot(&buf)); err != nil {
236238
return "", xerrors.Errorf("capture screenshot: %w", err)
237239
}
238-
fname := fmt.Sprintf("scaletest-dashboard-%s-%s.png", name, time.Now().Format("20060102-150405"))
240+
randExt, err := cryptorand.String(4)
241+
if err != nil {
242+
// this should never happen
243+
return "", xerrors.Errorf("generate random string: %w", err)
244+
}
245+
fname := fmt.Sprintf("scaletest-dashboard-%s-%s-%s.png", name, time.Now().Format("20060102-150405"), randExt)
239246
pwd := os.Getenv("PWD")
240247
fpath := filepath.Join(pwd, fname)
241248
f, err := os.OpenFile(fpath, os.O_CREATE|os.O_WRONLY, 0o644)

0 commit comments

Comments
 (0)