From 6bf9c32c07982f537ed1fbcfc9bcb93b9ac9b668 Mon Sep 17 00:00:00 2001 From: go-jet Date: Tue, 30 Jul 2019 11:45:10 +0200 Subject: [PATCH] Tests folder structure reorganisation. --- README.md | 2 +- tests/mysql/sample_test.go | 2 +- tests/{ => postgres}/all_types_test.go | 6 ++---- tests/{ => postgres}/chinook_db_test.go | 4 ++-- tests/{ => postgres}/delete_test.go | 2 +- tests/{ => postgres}/insert_test.go | 2 +- tests/{ => postgres}/lock_test.go | 2 +- tests/{ => postgres}/main_test.go | 2 +- tests/{ => postgres}/northwind_test.go | 4 ++-- tests/{ => postgres}/sample_test.go | 2 +- tests/{ => postgres}/scan_test.go | 4 ++-- tests/{ => postgres}/select_test.go | 10 +++++----- tests/{ => postgres}/testdata/joined_everything.json | 0 tests/{ => postgres}/testdata/northwind-all.json | 0 tests/{ => postgres}/testdata/quick-start-dest.json | 0 tests/{ => postgres}/testdata/quick-start-dest2.json | 0 tests/{ => postgres}/update_test.go | 2 +- tests/{ => postgres}/util_test.go | 2 +- .../{common_db_results => common}/bool_operators.json | 0 19 files changed, 22 insertions(+), 24 deletions(-) rename tests/{ => postgres}/all_types_test.go (99%) rename tests/{ => postgres}/chinook_db_test.go (98%) rename tests/{ => postgres}/delete_test.go (99%) rename tests/{ => postgres}/insert_test.go (99%) rename tests/{ => postgres}/lock_test.go (98%) rename tests/{ => postgres}/main_test.go (99%) rename tests/{ => postgres}/northwind_test.go (95%) rename tests/{ => postgres}/sample_test.go (99%) rename tests/{ => postgres}/scan_test.go (99%) rename tests/{ => postgres}/select_test.go (99%) rename tests/{ => postgres}/testdata/joined_everything.json (100%) rename tests/{ => postgres}/testdata/northwind-all.json (100%) rename tests/{ => postgres}/testdata/quick-start-dest.json (100%) rename tests/{ => postgres}/testdata/quick-start-dest2.json (100%) rename tests/{ => postgres}/update_test.go (99%) rename tests/{ => postgres}/util_test.go (99%) rename tests/testdata/{common_db_results => common}/bool_operators.json (100%) diff --git a/README.md b/README.md index 035c51f..f83d89a 100644 --- a/README.md +++ b/README.md @@ -508,7 +508,7 @@ return result in one database call. Handler execution will be only proportional ORM example replaced with jet will take just 30ms + 'result scan time' = 31ms (rough estimate). With Jet you can even join the whole database and store the whole structured result in in one query call. -This is exactly what is being done in one of the tests: [TestJoinEverything](/tests/chinook_db_test.go#L40). +This is exactly what is being done in one of the tests: [TestJoinEverything](/tests/postgres/chinook_db_test.go#L40). The whole test database is joined and query result(~10,000 rows) is stored in a structured variable in less than 0.7s. ##### How quickly bugs are found diff --git a/tests/mysql/sample_test.go b/tests/mysql/sample_test.go index 78f9895..8432c72 100644 --- a/tests/mysql/sample_test.go +++ b/tests/mysql/sample_test.go @@ -95,7 +95,7 @@ FROM test_sample.all_types; testutils.JsonPrint(dest) - testutils.AssertJSONFile(t, "./testdata/common_db_results/bool_operators.json", dest) + testutils.AssertJSONFile(t, "./testdata/common/bool_operators.json", dest) } var allTypesJson = ` diff --git a/tests/all_types_test.go b/tests/postgres/all_types_test.go similarity index 99% rename from tests/all_types_test.go rename to tests/postgres/all_types_test.go index 5050517..0107009 100644 --- a/tests/all_types_test.go +++ b/tests/postgres/all_types_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( . "github.com/go-jet/jet" @@ -240,9 +240,7 @@ LIMIT $5; assert.NilError(t, err) - testutils.JsonPrint(dest) - - testutils.AssertJSONFile(t, "./testdata/common_db_results/bool_operators.json", dest) + testutils.AssertJSONFile(t, "./testdata/common/bool_operators.json", dest) } func TestFloatOperators(t *testing.T) { diff --git a/tests/chinook_db_test.go b/tests/postgres/chinook_db_test.go similarity index 98% rename from tests/chinook_db_test.go rename to tests/postgres/chinook_db_test.go index 0a22cf8..a5dd145 100644 --- a/tests/chinook_db_test.go +++ b/tests/postgres/chinook_db_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( "context" @@ -102,7 +102,7 @@ func TestJoinEverything(t *testing.T) { assert.NilError(t, err) assert.Equal(t, len(dest), 275) - testutils.AssertJSONFile(t, "./testdata/joined_everything.json", dest) + testutils.AssertJSONFile(t, "./postgres/testdata/joined_everything.json", dest) } func TestSelfJoin(t *testing.T) { diff --git a/tests/delete_test.go b/tests/postgres/delete_test.go similarity index 99% rename from tests/delete_test.go rename to tests/postgres/delete_test.go index 639aae2..c17f927 100644 --- a/tests/delete_test.go +++ b/tests/postgres/delete_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( "context" diff --git a/tests/insert_test.go b/tests/postgres/insert_test.go similarity index 99% rename from tests/insert_test.go rename to tests/postgres/insert_test.go index 54e341a..22ca26f 100644 --- a/tests/insert_test.go +++ b/tests/postgres/insert_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( "context" diff --git a/tests/lock_test.go b/tests/postgres/lock_test.go similarity index 98% rename from tests/lock_test.go rename to tests/postgres/lock_test.go index b266a54..d10f7be 100644 --- a/tests/lock_test.go +++ b/tests/postgres/lock_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( "context" diff --git a/tests/main_test.go b/tests/postgres/main_test.go similarity index 99% rename from tests/main_test.go rename to tests/postgres/main_test.go index 90a7d23..7b77afb 100644 --- a/tests/main_test.go +++ b/tests/postgres/main_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( "bytes" diff --git a/tests/northwind_test.go b/tests/postgres/northwind_test.go similarity index 95% rename from tests/northwind_test.go rename to tests/postgres/northwind_test.go index e84cdca..2a5a59a 100644 --- a/tests/northwind_test.go +++ b/tests/postgres/northwind_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( "github.com/go-jet/jet/internal/testutils" @@ -62,5 +62,5 @@ func TestNorthwindJoinEverything(t *testing.T) { assert.NilError(t, err) //jsonSave("./testdata/northwind-all.json", dest) - testutils.AssertJSONFile(t, "./testdata/northwind-all.json", dest) + testutils.AssertJSONFile(t, "./postgres/testdata/northwind-all.json", dest) } diff --git a/tests/sample_test.go b/tests/postgres/sample_test.go similarity index 99% rename from tests/sample_test.go rename to tests/postgres/sample_test.go index f335d84..a789e15 100644 --- a/tests/sample_test.go +++ b/tests/postgres/sample_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( . "github.com/go-jet/jet" diff --git a/tests/scan_test.go b/tests/postgres/scan_test.go similarity index 99% rename from tests/scan_test.go rename to tests/postgres/scan_test.go index d3b06fa..c0c4746 100644 --- a/tests/scan_test.go +++ b/tests/postgres/scan_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( . "github.com/go-jet/jet" @@ -182,7 +182,7 @@ func TestScanToStruct(t *testing.T) { err := query.Query(db, &dest) - assert.Error(t, err, `Scan: unable to scan type int32 into UUID, at struct field: InventoryID uuid.UUID of type tests.Inventory. `) + assert.Error(t, err, `Scan: unable to scan type int32 into UUID, at struct field: InventoryID uuid.UUID of type postgres.Inventory. `) }) } diff --git a/tests/select_test.go b/tests/postgres/select_test.go similarity index 99% rename from tests/select_test.go rename to tests/postgres/select_test.go index b198e73..33e9c59 100644 --- a/tests/select_test.go +++ b/tests/postgres/select_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( . "github.com/go-jet/jet" @@ -1459,7 +1459,7 @@ ORDER BY actor.actor_id ASC, film.film_id ASC; assert.NilError(t, err) //jsonSave("./testdata/quick-start-dest.json", dest) - testutils.AssertJSONFile(t, "./testdata/quick-start-dest.json", dest) + testutils.AssertJSONFile(t, "./postgres/testdata/quick-start-dest.json", dest) var dest2 []struct { model.Category @@ -1472,7 +1472,7 @@ ORDER BY actor.actor_id ASC, film.film_id ASC; assert.NilError(t, err) //jsonSave("./testdata/quick-start-dest2.json", dest2) - testutils.AssertJSONFile(t, "./testdata/quick-start-dest2.json", dest2) + testutils.AssertJSONFile(t, "./postgres/testdata/quick-start-dest2.json", dest2) } func TestQuickStartWithSubQueries(t *testing.T) { @@ -1524,7 +1524,7 @@ func TestQuickStartWithSubQueries(t *testing.T) { assert.NilError(t, err) //jsonSave("./testdata/quick-start-dest.json", dest) - testutils.AssertJSONFile(t, "./testdata/quick-start-dest.json", dest) + testutils.AssertJSONFile(t, "./postgres/testdata/quick-start-dest.json", dest) var dest2 []struct { model.Category @@ -1537,5 +1537,5 @@ func TestQuickStartWithSubQueries(t *testing.T) { assert.NilError(t, err) //jsonSave("./testdata/quick-start-dest2.json", dest2) - testutils.AssertJSONFile(t, "./testdata/quick-start-dest2.json", dest2) + testutils.AssertJSONFile(t, "./postgres/testdata/quick-start-dest2.json", dest2) } diff --git a/tests/testdata/joined_everything.json b/tests/postgres/testdata/joined_everything.json similarity index 100% rename from tests/testdata/joined_everything.json rename to tests/postgres/testdata/joined_everything.json diff --git a/tests/testdata/northwind-all.json b/tests/postgres/testdata/northwind-all.json similarity index 100% rename from tests/testdata/northwind-all.json rename to tests/postgres/testdata/northwind-all.json diff --git a/tests/testdata/quick-start-dest.json b/tests/postgres/testdata/quick-start-dest.json similarity index 100% rename from tests/testdata/quick-start-dest.json rename to tests/postgres/testdata/quick-start-dest.json diff --git a/tests/testdata/quick-start-dest2.json b/tests/postgres/testdata/quick-start-dest2.json similarity index 100% rename from tests/testdata/quick-start-dest2.json rename to tests/postgres/testdata/quick-start-dest2.json diff --git a/tests/update_test.go b/tests/postgres/update_test.go similarity index 99% rename from tests/update_test.go rename to tests/postgres/update_test.go index 9dcf7ba..314f5d6 100644 --- a/tests/update_test.go +++ b/tests/postgres/update_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( "context" diff --git a/tests/util_test.go b/tests/postgres/util_test.go similarity index 99% rename from tests/util_test.go rename to tests/postgres/util_test.go index a378742..00210eb 100644 --- a/tests/util_test.go +++ b/tests/postgres/util_test.go @@ -1,4 +1,4 @@ -package tests +package postgres import ( "github.com/go-jet/jet" diff --git a/tests/testdata/common_db_results/bool_operators.json b/tests/testdata/common/bool_operators.json similarity index 100% rename from tests/testdata/common_db_results/bool_operators.json rename to tests/testdata/common/bool_operators.json