refactor platform logic and add gasorder domain
This commit is contained in:
30
backend/api/internal/logic/platform/dashboard_test.go
Normal file
30
backend/api/internal/logic/platform/dashboard_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package platform
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/models"
|
||||
"github.com/DATA-DOG/go-sqlmock"
|
||||
)
|
||||
|
||||
func TestDashboardOverviewReturnsZeroValuesForAnEmptyDatabase(t *testing.T) {
|
||||
_, mock := setupPlatformRoleDatabase(t)
|
||||
for _, query := range []string{
|
||||
`SELECT count\(\*\) FROM "gas_basic" WHERE status = \$1`,
|
||||
`SELECT count\(\*\) FROM "delivery_basic" WHERE status = \$1`,
|
||||
`SELECT count\(\*\) FROM "staff_account" WHERE work_status = \$1`,
|
||||
`SELECT count\(\*\) FROM "user_account" WHERE status = \$1`,
|
||||
} {
|
||||
mock.ExpectQuery(regexp.MustCompile(query).String()).WithArgs(sqlmock.AnyArg()).WillReturnRows(sqlmock.NewRows([]string{"count"}).AddRow(0))
|
||||
}
|
||||
|
||||
overview, err := models.GetDashboardOverview()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if overview != (models.DashboardOverview{}) {
|
||||
t.Fatalf("empty dashboard = %#v, want zero values", overview)
|
||||
}
|
||||
assertMockExpectations(t, mock)
|
||||
}
|
||||
Reference in New Issue
Block a user