Skip to content

Commit

Permalink
Fix some previously updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbantle22 committed Jul 11, 2023
1 parent db73fce commit 1faab30
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
4 changes: 0 additions & 4 deletions integration-tests/mysql-client-tests/node/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export function assertQueryResult(q, resultStr, expected, rows, matcher) {
if (q.toLowerCase().includes("dolt_commit")) {
return rows.length === 1 && rows[0].hash.length === 32;
}
if (q.toLowerCase().includes("dolt_merge")) {
const result = JSON.parse(resultStr);
return expected.fast_forward === result.fast_forward && expected.conflicts === result.conflicts;
}
return resultStr === JSON.stringify(expected);
}

Expand Down
10 changes: 8 additions & 2 deletions integration-tests/mysql-client-tests/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ const tests = [
{ q: "call dolt_add('-A');", res: [{ status: 0 }] },
{ q: "call dolt_commit('-m', 'my commit')", res: [] },
{ q: "select COUNT(*) FROM dolt_log", res: [{ "COUNT(*)": 2 }] },
{ q: "call dolt_checkout('-b', 'mybranch')", res: [{ status: 0, message: "Switched to branch 'mybranch'" }] },
{
q: "call dolt_checkout('-b', 'mybranch')",
res: [{ status: 0, message: "Switched to branch 'mybranch'" }],
},
{
q: "insert into test (pk, `value`) values (1,1)",
res: {
Expand All @@ -63,7 +66,10 @@ const tests = [
},
},
{ q: "call dolt_commit('-a', '-m', 'my commit2')", res: [] },
{ q: "call dolt_checkout('main')", res: [{ status: 0, message: "Switched to branch 'main'" }] },
{
q: "call dolt_checkout('main')",
res: [{ status: 0, message: "Switched to branch 'main'" }],
},
{
q: "call dolt_merge('mybranch')",
res: [{ fast_forward: 1, conflicts: 0 }],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ export function mergeBaseMatcher(rows, exp) {
return true;
}

export function mergeMatcher(rows, exp) {
const exceptionKeys = ["hash"];

function getExceptionIsValid(row, key) {
const val = row[key];
switch (key) {
case "hash":
return commitHashIsValid(val);
default:
return false;
}
}

return matcher(rows, exp, exceptionKeys, getExceptionIsValid);
}

export function tagsMatcher(rows, exp) {
const exceptionKeys = ["tag_hash", "date"];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { logsMatcher, mergeBaseMatcher } from "./matchers.js";
import { logsMatcher, mergeBaseMatcher, mergeMatcher } from "./matchers.js";

export const mergeTests = [
{
Expand All @@ -14,7 +14,8 @@ export const mergeTests = [
{
q: `CALL DOLT_MERGE(:branchName, "--no-ff", "-m", :commitMsg)`,
p: { branchName: "mybranch", commitMsg: "Merge mybranch into main" },
res: [{ fast_forward: 0, conflicts: 0 }],
res: [{ hash: "", fast_forward: 0, conflicts: 0 }],
matcher: mergeMatcher,
},
{
q: `SELECT * FROM DOLT_LOG(:refName, '--parents') LIMIT :limit OFFSET :offset`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const tableTests = [
FROM information_schema.statistics
WHERE table_schema=:tableSchema AND table_name=:tableName AND index_name!="PRIMARY"
GROUP BY index_name;`,
p: { tableSchema: `${dbName}`, tableName: "test" },
p: { tableSchema: `${dbName}/main`, tableName: "test" },
res: [
{
TABLE_NAME: "test",
Expand Down Expand Up @@ -122,19 +122,19 @@ export const tableTests = [
},
{
q: `SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE table_name=:tableName AND table_schema=:tableSchema AND referenced_table_schema IS NOT NULL`,
p: { tableName: "test_info", tableSchema: `${dbName}` },
p: { tableName: "test_info", tableSchema: `${dbName}/main` },
res: [
{
CONSTRAINT_CATALOG: "def",
CONSTRAINT_SCHEMA: `${dbName}`,
CONSTRAINT_SCHEMA: `${dbName}/main`,
CONSTRAINT_NAME: "s7utamh8",
TABLE_CATALOG: "def",
TABLE_SCHEMA: `${dbName}`,
TABLE_SCHEMA: `${dbName}/main`,
TABLE_NAME: "test_info",
COLUMN_NAME: "test_pk",
ORDINAL_POSITION: 1,
POSITION_IN_UNIQUE_CONSTRAINT: 1,
REFERENCED_TABLE_SCHEMA: `${dbName}`,
REFERENCED_TABLE_SCHEMA: dbName,
REFERENCED_TABLE_NAME: "test",
REFERENCED_COLUMN_NAME: "pk",
},
Expand Down Expand Up @@ -270,7 +270,7 @@ export const tableTests = [
},
{
q: "CALL DOLT_CHECKOUT('test_info')",
res: [{ status: 0 }],
res: [{ status: 0, message: "" }],
},
{
q: `SELECT * FROM dolt_status`,
Expand Down

0 comments on commit 1faab30

Please sign in to comment.