Skip to content

Commit

Permalink
Merge pull request #1003 from dolthub/taylor/docs-tests
Browse files Browse the repository at this point in the history
Add diff tests for dolt.docs
  • Loading branch information
tbantle22 authored Nov 22, 2024
2 parents c1c5f6e + b5baaa6 commit 9407941
Showing 1 changed file with 146 additions and 103 deletions.
249 changes: 146 additions & 103 deletions testing/go/dolt_tables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,152 @@ func TestUserSpaceDoltTables(t *testing.T) {
},
},
},
{
Name: "dolt docs",
SetUpScript: []string{
"INSERT INTO dolt.docs values ('README.md', 'testing')",
},
Assertions: []ScriptTestAssertion{
{
Query: `SELECT * FROM dolt.docs`,
Expected: []sql.Row{
{"README.md", "testing"},
},
},
{
Query: `SELECT * FROM dolt_docs`,
Expected: []sql.Row{
{"README.md", "testing"},
},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.docs.doc_name FROM dolt.docs`,
Expected: []sql.Row{{"README.md"}},
},
{
Skip: true, // TODO: table not found: dolt_docs
Query: `SELECT dolt_docs.doc_name FROM dolt_docs`,
Expected: []sql.Row{{"README.md"}},
},
{
Query: `SELECT * FROM public.docs`,
ExpectedErr: "table not found",
},
{
Query: `SELECT * FROM docs`,
ExpectedErr: "table not found",
},
{
Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING')`,
Expected: []sql.Row{
{"", "dolt.docs", "added", 1, 1},
},
},
{
Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING', 'docs')`,
Expected: []sql.Row{
{"", "dolt.docs", "added", 1, 1},
},
},
{
Skip: true, // TODO: we should support this
Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING', 'dolt_docs')`,
Expected: []sql.Row{
{"", "dolt_docs", "added", 1, 1},
},
},
{
Skip: true, // TODO: we should support this or a --schema flag
Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING', 'dolt.docs')`,
Expected: []sql.Row{
{"", "dolt.docs", "added", 1, 1},
},
},
{
Query: `SELECT * FROM dolt_diff_summary('main', 'WORKING', 'docs')`,
Expected: []sql.Row{
{"", "dolt.docs", "added", 1, 1},
},
},
{
Query: `SELECT diff_type, from_doc_name, to_doc_name FROM dolt_diff('main', 'WORKING', 'docs')`,
Expected: []sql.Row{
{"added", nil, "README.md"},
},
},
{
Query: `SELECT diff_type, from_doc_name, to_doc_name FROM dolt_diff('main', 'WORKING', 'docs')`,
Expected: []sql.Row{
{"added", nil, "README.md"},
},
},
{
Query: `CREATE TABLE docs (id INT PRIMARY KEY)`,
Expected: []sql.Row{},
},
{
Query: `INSERT INTO docs VALUES (1)`,
Expected: []sql.Row{},
},
{
Query: `SELECT * FROM docs`,
Expected: []sql.Row{{1}},
},
{
Query: `SELECT doc_name FROM dolt.docs`,
Expected: []sql.Row{{"README.md"}},
},
{
Query: "SET search_path = 'dolt'",
Expected: []sql.Row{},
},
{
Query: `SELECT doc_name FROM docs`,
Expected: []sql.Row{{"README.md"}},
},
{
Query: `SELECT * FROM public.docs`,
Expected: []sql.Row{{1}},
},
{
Query: "SET search_path = 'public'",
Expected: []sql.Row{},
},
{
Query: `SELECT * FROM docs`,
Expected: []sql.Row{{1}},
},
{
Query: "SET search_path = 'public,dolt'",
Expected: []sql.Row{},
},
{
Query: `SELECT * FROM docs`,
Expected: []sql.Row{{1}},
},
{
Query: `SELECT * FROM DOCS`,
Expected: []sql.Row{{1}},
},
{
Query: "SET search_path = 'public'",
Expected: []sql.Row{},
},
{
Query: `DELETE FROM dolt.docs WHERE doc_name = 'README.md'`,
Expected: []sql.Row{},
},
{
Query: `SELECT * FROM dolt.docs`,
Expected: []sql.Row{},
},
{
Query: `DELETE FROM dolt_docs WHERE doc_name = 'README.md'`,
Expected: []sql.Row{},
},
},
},
{
Name: "dolt diff",
SetUpScript: []string{
Expand Down Expand Up @@ -1661,109 +1807,6 @@ func TestUserSpaceDoltTables(t *testing.T) {
},
},
},
{
Name: "dolt docs",
SetUpScript: []string{
"INSERT INTO dolt.docs values ('README.md', 'testing')",
},
Assertions: []ScriptTestAssertion{
{
Query: `SELECT * FROM dolt.docs`,
Expected: []sql.Row{
{"README.md", "testing"},
},
},
{
Query: `SELECT * FROM dolt_docs`,
Expected: []sql.Row{
{"README.md", "testing"},
},
},
{
Skip: true, // TODO: referencing items outside the schema or database is not yet supported
Query: `SELECT dolt.docs.doc_name FROM dolt.docs`,
Expected: []sql.Row{{"README.md"}},
},
{
Skip: true, // TODO: table not found: dolt_docs
Query: `SELECT dolt_docs.doc_name FROM dolt_docs`,
Expected: []sql.Row{{"README.md"}},
},
{
Query: `SELECT * FROM public.docs`,
ExpectedErr: "table not found",
},
{
Query: `SELECT * FROM docs`,
ExpectedErr: "table not found",
},
{
Query: `CREATE TABLE docs (id INT PRIMARY KEY)`,
Expected: []sql.Row{},
},
{
Query: `INSERT INTO docs VALUES (1)`,
Expected: []sql.Row{},
},
{
Query: `SELECT * FROM docs`,
Expected: []sql.Row{{1}},
},
{
Query: `SELECT doc_name FROM dolt.docs`,
Expected: []sql.Row{{"README.md"}},
},
{
Query: "SET search_path = 'dolt'",
Expected: []sql.Row{},
},
{
Query: `SELECT doc_name FROM docs`,
Expected: []sql.Row{{"README.md"}},
},
{
Query: `SELECT * FROM public.docs`,
Expected: []sql.Row{{1}},
},
{
Query: "SET search_path = 'public'",
Expected: []sql.Row{},
},
{
Query: `SELECT * FROM docs`,
Expected: []sql.Row{{1}},
},
{
Query: "SET search_path = 'public,dolt'",
Expected: []sql.Row{},
},
{
Query: `SELECT * FROM docs`,
Expected: []sql.Row{{1}},
},
{
Query: `SELECT * FROM DOCS`,
Expected: []sql.Row{{1}},
},
{
Query: "SET search_path = 'public'",
Expected: []sql.Row{},
},
{
Query: `DELETE FROM dolt.docs WHERE doc_name = 'README.md'`,
Expected: []sql.Row{},
},
{
Query: `SELECT * FROM dolt.docs`,
Expected: []sql.Row{},
},
{
Query: `DELETE FROM dolt_docs WHERE doc_name = 'README.md'`,
Expected: []sql.Row{},
},
// TODO: Test dolt.docs in diffs
},
},
{
Name: "dolt procedures",
SetUpScript: []string{
Expand Down

0 comments on commit 9407941

Please sign in to comment.