Stop generating bob test files
They just slow things down.
This commit is contained in:
parent
4ca734cc10
commit
d377d9a7d2
13 changed files with 1 additions and 2311 deletions
|
|
@ -1,9 +0,0 @@
|
|||
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package dberrors
|
||||
|
||||
import "github.com/stephenafamo/bob"
|
||||
|
||||
// Set the testDB to enable tests that use the database
|
||||
var testDB bob.Transactor[bob.Tx]
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package dberrors
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
factory "github.com/Gleipnir-Technology/nidus-sync/db/factory"
|
||||
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/stephenafamo/bob"
|
||||
)
|
||||
|
||||
func TestH3AggregationUniqueConstraintErrors(t *testing.T) {
|
||||
if testDB == nil {
|
||||
t.Skip("No database connection provided")
|
||||
}
|
||||
|
||||
f := factory.New()
|
||||
tests := []struct {
|
||||
name string
|
||||
expectedErr *UniqueConstraintError
|
||||
conflictMods func(context.Context, *testing.T, bob.Executor, *models.H3Aggregation) factory.H3AggregationModSlice
|
||||
}{
|
||||
{
|
||||
name: "ErrUniqueH3AggregationPkey",
|
||||
expectedErr: H3AggregationErrors.ErrUniqueH3AggregationPkey,
|
||||
conflictMods: func(ctx context.Context, t *testing.T, exec bob.Executor, obj *models.H3Aggregation) factory.H3AggregationModSlice {
|
||||
shouldUpdate := false
|
||||
updateMods := make(factory.H3AggregationModSlice, 0, 1)
|
||||
|
||||
if shouldUpdate {
|
||||
if err := obj.Update(ctx, exec, f.NewH3AggregationWithContext(ctx, updateMods...).BuildSetter()); err != nil {
|
||||
t.Fatalf("Error updating object: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return factory.H3AggregationModSlice{
|
||||
factory.H3AggregationMods.ID(obj.ID),
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ErrUniqueH3AggregationCellOrganizationIdType_Key",
|
||||
expectedErr: H3AggregationErrors.ErrUniqueH3AggregationCellOrganizationIdType_Key,
|
||||
conflictMods: func(ctx context.Context, t *testing.T, exec bob.Executor, obj *models.H3Aggregation) factory.H3AggregationModSlice {
|
||||
shouldUpdate := false
|
||||
updateMods := make(factory.H3AggregationModSlice, 0, 3)
|
||||
|
||||
if shouldUpdate {
|
||||
if err := obj.Update(ctx, exec, f.NewH3AggregationWithContext(ctx, updateMods...).BuildSetter()); err != nil {
|
||||
t.Fatalf("Error updating object: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return factory.H3AggregationModSlice{
|
||||
factory.H3AggregationMods.Cell(obj.Cell),
|
||||
factory.H3AggregationMods.OrganizationID(obj.OrganizationID),
|
||||
factory.H3AggregationMods.Type(obj.Type),
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
t.Cleanup(cancel)
|
||||
|
||||
tx, err := testDB.Begin(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("Couldn't start database transaction: %v", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := tx.Rollback(ctx); err != nil {
|
||||
t.Fatalf("Error rolling back transaction: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
var exec bob.Executor = tx
|
||||
|
||||
obj, err := f.NewH3AggregationWithContext(ctx, factory.H3AggregationMods.WithParentsCascading()).Create(ctx, exec)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
obj2, err := f.NewH3AggregationWithContext(ctx).Create(ctx, exec)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = obj2.Update(ctx, exec, f.NewH3AggregationWithContext(ctx, tt.conflictMods(ctx, t, exec, obj)...).BuildSetter())
|
||||
if !errors.Is(ErrUniqueConstraint, err) {
|
||||
t.Fatalf("Expected: %s, Got: %v", tt.name, err)
|
||||
}
|
||||
if !errors.Is(tt.expectedErr, err) {
|
||||
t.Fatalf("Expected: %s, Got: %v", tt.expectedErr.Error(), err)
|
||||
}
|
||||
if !ErrUniqueConstraint.Is(err) {
|
||||
t.Fatalf("Expected: %s, Got: %v", tt.name, err)
|
||||
}
|
||||
if !tt.expectedErr.Is(err) {
|
||||
t.Fatalf("Expected: %s, Got: %v", tt.expectedErr.Error(), err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
// Code generated by BobGen psql v0.0.4-0.20260105020634-53e08d840e47+dirty. DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package dberrors
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
factory "github.com/Gleipnir-Technology/nidus-sync/db/factory"
|
||||
models "github.com/Gleipnir-Technology/nidus-sync/db/models"
|
||||
"github.com/stephenafamo/bob"
|
||||
)
|
||||
|
||||
func TestPublicreportQuickUniqueConstraintErrors(t *testing.T) {
|
||||
if testDB == nil {
|
||||
t.Skip("No database connection provided")
|
||||
}
|
||||
|
||||
f := factory.New()
|
||||
tests := []struct {
|
||||
name string
|
||||
expectedErr *UniqueConstraintError
|
||||
conflictMods func(context.Context, *testing.T, bob.Executor, *models.PublicreportQuick) factory.PublicreportQuickModSlice
|
||||
}{
|
||||
{
|
||||
name: "ErrUniqueQuickPkey",
|
||||
expectedErr: PublicreportQuickErrors.ErrUniqueQuickPkey,
|
||||
conflictMods: func(ctx context.Context, t *testing.T, exec bob.Executor, obj *models.PublicreportQuick) factory.PublicreportQuickModSlice {
|
||||
shouldUpdate := false
|
||||
updateMods := make(factory.PublicreportQuickModSlice, 0, 1)
|
||||
|
||||
if shouldUpdate {
|
||||
if err := obj.Update(ctx, exec, f.NewPublicreportQuickWithContext(ctx, updateMods...).BuildSetter()); err != nil {
|
||||
t.Fatalf("Error updating object: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return factory.PublicreportQuickModSlice{
|
||||
factory.PublicreportQuickMods.ID(obj.ID),
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ErrUniqueQuickPublicIdKey",
|
||||
expectedErr: PublicreportQuickErrors.ErrUniqueQuickPublicIdKey,
|
||||
conflictMods: func(ctx context.Context, t *testing.T, exec bob.Executor, obj *models.PublicreportQuick) factory.PublicreportQuickModSlice {
|
||||
shouldUpdate := false
|
||||
updateMods := make(factory.PublicreportQuickModSlice, 0, 1)
|
||||
|
||||
if shouldUpdate {
|
||||
if err := obj.Update(ctx, exec, f.NewPublicreportQuickWithContext(ctx, updateMods...).BuildSetter()); err != nil {
|
||||
t.Fatalf("Error updating object: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
return factory.PublicreportQuickModSlice{
|
||||
factory.PublicreportQuickMods.PublicID(obj.PublicID),
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(t.Context())
|
||||
t.Cleanup(cancel)
|
||||
|
||||
tx, err := testDB.Begin(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("Couldn't start database transaction: %v", err)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := tx.Rollback(ctx); err != nil {
|
||||
t.Fatalf("Error rolling back transaction: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
var exec bob.Executor = tx
|
||||
|
||||
obj, err := f.NewPublicreportQuickWithContext(ctx, factory.PublicreportQuickMods.WithParentsCascading()).Create(ctx, exec)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
obj2, err := f.NewPublicreportQuickWithContext(ctx).Create(ctx, exec)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = obj2.Update(ctx, exec, f.NewPublicreportQuickWithContext(ctx, tt.conflictMods(ctx, t, exec, obj)...).BuildSetter())
|
||||
if !errors.Is(ErrUniqueConstraint, err) {
|
||||
t.Fatalf("Expected: %s, Got: %v", tt.name, err)
|
||||
}
|
||||
if !errors.Is(tt.expectedErr, err) {
|
||||
t.Fatalf("Expected: %s, Got: %v", tt.expectedErr.Error(), err)
|
||||
}
|
||||
if !ErrUniqueConstraint.Is(err) {
|
||||
t.Fatalf("Expected: %s, Got: %v", tt.name, err)
|
||||
}
|
||||
if !tt.expectedErr.Is(err) {
|
||||
t.Fatalf("Expected: %s, Got: %v", tt.expectedErr.Error(), err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue