Browse Source

test: error validation

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5747/head
Raju Udava 2 years ago
parent
commit
3a236654ae
  1. 12
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 30
      packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts

12
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -3700,7 +3700,7 @@ class BaseModelSqlv2 {
); );
NcError.unprocessableEntity( NcError.unprocessableEntity(
`Child record with id ${missingIds.join(', ')} not found`, `Child record with id [${missingIds.join(', ')}] not found`,
); );
} }
@ -3778,7 +3778,7 @@ class BaseModelSqlv2 {
); );
NcError.unprocessableEntity( NcError.unprocessableEntity(
`Child record with id ${missingIds.join(', ')} not found`, `Child record with id [${missingIds.join(', ')}] not found`,
); );
} }
} }
@ -3810,7 +3810,7 @@ class BaseModelSqlv2 {
if (!childRow) { if (!childRow) {
NcError.unprocessableEntity( NcError.unprocessableEntity(
`Child record with id ${childIds[0]} not found`, `Child record with id [${childIds[0]}] not found`,
); );
} }
} }
@ -3902,7 +3902,7 @@ class BaseModelSqlv2 {
); );
NcError.unprocessableEntity( NcError.unprocessableEntity(
`Child record with id ${missingIds.join(', ')} not found`, `Child record with id [${missingIds.join(', ')}] not found`,
); );
} }
} }
@ -3942,7 +3942,7 @@ class BaseModelSqlv2 {
); );
NcError.unprocessableEntity( NcError.unprocessableEntity(
`Child record with id ${missingIds.join(', ')} not found`, `Child record with id [${missingIds.join(', ')}] not found`,
); );
} }
} }
@ -3977,7 +3977,7 @@ class BaseModelSqlv2 {
if (!childRow) { if (!childRow) {
NcError.unprocessableEntity( NcError.unprocessableEntity(
`Child record with id ${childIds[0]} not found`, `Child record with id [${childIds[0]}] not found`,
); );
} }
} }

30
packages/nocodb/tests/unit/rest/tests/newDataApis.test.ts

@ -2312,7 +2312,7 @@ function linkBased() {
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, tableId: 9999 }, urlParams: { ...validParams.urlParams, tableId: 9999 },
status: 404, status: 404,
msg: "Table '9999' not found", msg: "Table with id '9999' not found",
}); });
// Link Add: Invalid link ID // Link Add: Invalid link ID
@ -2321,7 +2321,7 @@ function linkBased() {
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, linkId: 9999 }, urlParams: { ...validParams.urlParams, linkId: 9999 },
status: 404, status: 404,
msg: "Column '9999' not found", msg: "Column with id '9999' not found",
}); });
// Link Add: Invalid Source row ID // Link Add: Invalid Source row ID
@ -2330,7 +2330,7 @@ function linkBased() {
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, rowId: 9999 }, urlParams: { ...validParams.urlParams, rowId: 9999 },
status: 404, status: 404,
msg: "Row '9999' not found", msg: "Row with id '9999' not found",
}); });
// Body parameter error // Body parameter error
@ -2353,7 +2353,7 @@ function linkBased() {
...validParams, ...validParams,
body: [999, 998], body: [999, 998],
status: 422, status: 422,
msg: 'Child record with id 999, 998 invalid for belongs-to relation field. Should contain only one value', msg: 'Child record with id [999, 998] invalid for belongs-to relation field. Should contain only one value',
}); });
} else { } else {
// Link Add: Invalid body parameter - row id invalid // Link Add: Invalid body parameter - row id invalid
@ -2363,7 +2363,7 @@ function linkBased() {
...validParams, ...validParams,
body: [999, 998, 997], body: [999, 998, 997],
status: 422, status: 422,
msg: 'Child record with id 999, 998, 997 not found', msg: 'Child record with id [999, 998, 997] not found',
}); });
// Link Add: Invalid body parameter - repeated row id // Link Add: Invalid body parameter - repeated row id
@ -2373,7 +2373,7 @@ function linkBased() {
...validParams, ...validParams,
body: [1, 2, 1, 2], body: [1, 2, 1, 2],
status: 422, status: 422,
msg: 'Child record with id 1, 2, 1, 2 contains duplicate value', msg: 'Child record with id [1, 2, 1, 2] contains duplicate value',
}); });
} }
} }
@ -2385,7 +2385,7 @@ function linkBased() {
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, tableId: 9999 }, urlParams: { ...validParams.urlParams, tableId: 9999 },
status: 404, status: 404,
msg: "Table '9999' not found", msg: "Table with id '9999' not found",
}); });
// Link Remove: Invalid link ID // Link Remove: Invalid link ID
@ -2394,7 +2394,7 @@ function linkBased() {
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, linkId: 9999 }, urlParams: { ...validParams.urlParams, linkId: 9999 },
status: 404, status: 404,
msg: "Column '9999' not found", msg: "Column with id '9999' not found",
}); });
// Link Remove: Invalid Source row ID // Link Remove: Invalid Source row ID
@ -2403,7 +2403,7 @@ function linkBased() {
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, rowId: 9999 }, urlParams: { ...validParams.urlParams, rowId: 9999 },
status: 404, status: 404,
msg: "Row '9999' not found", msg: "Row with id '9999' not found",
}); });
// Body parameter error // Body parameter error
@ -2426,7 +2426,7 @@ function linkBased() {
...validParams, ...validParams,
body: [999, 998], body: [999, 998],
status: 422, status: 422,
msg: 'Child record with id 999, 998 invalid for belongs-to relation field. Should contain only one value', msg: 'Child record with id [999, 998] invalid for belongs-to relation field. Should contain only one value',
}); });
} else { } else {
// Link Remove: Invalid body parameter - row id invalid // Link Remove: Invalid body parameter - row id invalid
@ -2436,7 +2436,7 @@ function linkBased() {
...validParams, ...validParams,
body: [999, 998], body: [999, 998],
status: 422, status: 422,
msg: 'Child record with id 999, 998 not found', msg: 'Child record with id [999, 998] not found',
}); });
// Link Remove: Invalid body parameter - repeated row id // Link Remove: Invalid body parameter - repeated row id
@ -2446,7 +2446,7 @@ function linkBased() {
...validParams, ...validParams,
body: [1, 2, 1, 2], body: [1, 2, 1, 2],
status: 422, status: 422,
msg: 'Child record with id 1, 2, 1, 2 contains duplicate value', msg: 'Child record with id [1, 2, 1, 2] contains duplicate value',
}); });
} }
} }
@ -2458,7 +2458,7 @@ function linkBased() {
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, tableId: 9999 }, urlParams: { ...validParams.urlParams, tableId: 9999 },
status: 404, status: 404,
msg: "Table '9999' not found", msg: "Table with id '9999' not found",
}); });
// Link List: Invalid link ID // Link List: Invalid link ID
@ -2467,7 +2467,7 @@ function linkBased() {
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, linkId: 9999 }, urlParams: { ...validParams.urlParams, linkId: 9999 },
status: 404, status: 404,
msg: "Column '9999' not found", msg: "Column with id '9999' not found",
}); });
// Link List: Invalid Source row ID // Link List: Invalid Source row ID
@ -2476,7 +2476,7 @@ function linkBased() {
...validParams, ...validParams,
urlParams: { ...validParams.urlParams, rowId: 9999 }, urlParams: { ...validParams.urlParams, rowId: 9999 },
status: 404, status: 404,
msg: "Row '9999' not found", msg: "Row with id '9999' not found",
}); });
// Query parameter error // Query parameter error

Loading…
Cancel
Save