From 748219d93e8b39313fbc337e34d14112abc9c915 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sun, 22 Jan 2023 20:43:01 -0800 Subject: [PATCH] Use a random number instead of hard coded in test --- test/automated/api/configmanagement.test.js | 2 +- test/automated/api/lib/rand.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/automated/api/configmanagement.test.js b/test/automated/api/configmanagement.test.js index 82f55fda4..a2b614a13 100644 --- a/test/automated/api/configmanagement.test.js +++ b/test/automated/api/configmanagement.test.js @@ -92,7 +92,7 @@ const appearanceValues = { const streamOutputVariants = { videoBitrate: randomNumber() * 100, framerate: 42, - cpuUsageLevel: 2, + cpuUsageLevel: randomNumber(4, 0), scaledHeight: randomNumber() * 100, scaledWidth: randomNumber() * 100, }; diff --git a/test/automated/api/lib/rand.js b/test/automated/api/lib/rand.js index 3b4536750..44e733b49 100644 --- a/test/automated/api/lib/rand.js +++ b/test/automated/api/lib/rand.js @@ -2,14 +2,14 @@ const crypto = require('crypto'); const Random = require('crypto-random'); //returns a random number in range of [1 - max] -function randomNumber(max = 5) { - return Random.range(1, max); +function randomNumber(max = 5, min = 1) { + return Random.range(0, max); } //returns a random hex string function randomString(length = 20) { - const bytesCount = Math.ceil(length / 2); - return crypto.randomBytes(bytesCount).toString('hex').substring(0, length); + const bytesCount = Math.ceil(length / 2); + return crypto.randomBytes(bytesCount).toString('hex').substring(0, length); } module.exports.randomNumber = randomNumber;