Bug 40174: Set minLength to 3
When we generate several objects we often get "Duplicate ID" from the
server. This mostly happens when the tests failed previously and the
objects have not been removed from the DB.
Signed-off-by: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 7f8e4fd4b5)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
62bcd78596
commit
b850118d3d
|
|
@ -14,9 +14,24 @@ const generateMockData = (type, properties) => {
|
|||
switch (type) {
|
||||
case "string":
|
||||
if (properties?.maxLength) {
|
||||
// The propability to have a string with length=1 is the same as length=10
|
||||
// We have very limited pool of possible values for length=1 which will result in a "Duplicate ID" error from the server
|
||||
// Setting minLength to 3 to prevent this kind of failures
|
||||
let minLength =
|
||||
properties.minLength === 1 ||
|
||||
properties.minLength === undefined
|
||||
? 3
|
||||
: properties.minLength;
|
||||
|
||||
if (
|
||||
properties.maxLength !== undefined &&
|
||||
properties.maxLength < minLength
|
||||
) {
|
||||
minLength = properties.maxLength;
|
||||
}
|
||||
return (value = faker.string.alpha({
|
||||
length: {
|
||||
min: properties.minLength || 1,
|
||||
min: minLength,
|
||||
max: properties.maxLength,
|
||||
},
|
||||
}));
|
||||
|
|
|
|||
Loading…
Reference in New Issue