Tests folder structure reorganisation.
This commit is contained in:
parent
d0533f73fb
commit
6bf9c32c07
19 changed files with 22 additions and 24 deletions
66
tests/postgres/northwind_test.go
Normal file
66
tests/postgres/northwind_test.go
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"github.com/go-jet/jet/internal/testutils"
|
||||
"github.com/go-jet/jet/tests/.gentestdata/jetdb/northwind/model"
|
||||
. "github.com/go-jet/jet/tests/.gentestdata/jetdb/northwind/table"
|
||||
"gotest.tools/assert"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNorthwindJoinEverything(t *testing.T) {
|
||||
|
||||
stmt := Customers.
|
||||
LEFT_JOIN(CustomerCustomerDemo, Customers.CustomerID.EQ(CustomerCustomerDemo.CustomerID)).
|
||||
LEFT_JOIN(CustomerDemographics, CustomerCustomerDemo.CustomerTypeID.EQ(CustomerDemographics.CustomerTypeID)).
|
||||
LEFT_JOIN(Orders, Orders.CustomerID.EQ(Customers.CustomerID)).
|
||||
LEFT_JOIN(Shippers, Orders.ShipVia.EQ(Shippers.ShipperID)).
|
||||
LEFT_JOIN(OrderDetails, Orders.OrderID.EQ(OrderDetails.OrderID)).
|
||||
LEFT_JOIN(Products, OrderDetails.ProductID.EQ(Products.ProductID)).
|
||||
LEFT_JOIN(Categories, Products.CategoryID.EQ(Categories.CategoryID)).
|
||||
LEFT_JOIN(Suppliers, Products.SupplierID.EQ(Suppliers.SupplierID)).
|
||||
LEFT_JOIN(Employees, Orders.EmployeeID.EQ(Employees.EmployeeID)).
|
||||
LEFT_JOIN(EmployeeTerritories, EmployeeTerritories.EmployeeID.EQ(Employees.EmployeeID)).
|
||||
LEFT_JOIN(Territories, EmployeeTerritories.TerritoryID.EQ(Territories.TerritoryID)).
|
||||
LEFT_JOIN(Region, Territories.RegionID.EQ(Region.RegionID)).
|
||||
SELECT(
|
||||
Customers.AllColumns,
|
||||
CustomerDemographics.AllColumns,
|
||||
Orders.AllColumns,
|
||||
Shippers.AllColumns,
|
||||
OrderDetails.AllColumns,
|
||||
Products.AllColumns,
|
||||
Categories.AllColumns,
|
||||
Suppliers.AllColumns,
|
||||
).
|
||||
ORDER_BY(Customers.CustomerID, Orders.OrderID, Products.ProductID)
|
||||
|
||||
var dest []struct {
|
||||
model.Customers
|
||||
|
||||
Demographics model.CustomerDemographics
|
||||
|
||||
Orders []struct {
|
||||
model.Orders
|
||||
|
||||
Shipper model.Shippers
|
||||
|
||||
Details struct {
|
||||
model.OrderDetails
|
||||
|
||||
Products []struct {
|
||||
model.Products
|
||||
|
||||
Category model.Categories
|
||||
Supplier model.Suppliers
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err := stmt.Query(db, &dest)
|
||||
assert.NilError(t, err)
|
||||
|
||||
//jsonSave("./testdata/northwind-all.json", dest)
|
||||
testutils.AssertJSONFile(t, "./postgres/testdata/northwind-all.json", dest)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue