diff --git a/db/bobgen.yaml b/db/bobgen.yaml index 7678b9a1..e5a60949 100644 --- a/db/bobgen.yaml +++ b/db/bobgen.yaml @@ -4,6 +4,7 @@ aliases: up_singular: "User" down_plural: "users" down_singular: "user" +no_tests: true psql: schemas: - "public" diff --git a/db/dberrors/bob_main.bob_test.go b/db/dberrors/bob_main.bob_test.go deleted file mode 100644 index 3632734f..00000000 --- a/db/dberrors/bob_main.bob_test.go +++ /dev/null @@ -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] diff --git a/db/dberrors/h3_aggregation.bob_test.go b/db/dberrors/h3_aggregation.bob_test.go deleted file mode 100644 index 107a168c..00000000 --- a/db/dberrors/h3_aggregation.bob_test.go +++ /dev/null @@ -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) - } - }) - } -} diff --git a/db/dberrors/publicreport.quick.bob_test.go b/db/dberrors/publicreport.quick.bob_test.go deleted file mode 100644 index f9b93a7a..00000000 --- a/db/dberrors/publicreport.quick.bob_test.go +++ /dev/null @@ -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) - } - }) - } -} diff --git a/db/factory/bobfactory_main.bob_test.go b/db/factory/bobfactory_main.bob_test.go deleted file mode 100644 index 5cd4ebd9..00000000 --- a/db/factory/bobfactory_main.bob_test.go +++ /dev/null @@ -1,1065 +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 factory - -import ( - "context" - "testing" -) - -func TestCreateFieldseekerContainerrelate(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerContainerrelateWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerContainerrelate: %v", err) - } -} - -func TestCreateFieldseekerFieldscoutinglog(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerFieldscoutinglogWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerFieldscoutinglog: %v", err) - } -} - -func TestCreateFieldseekerHabitatrelate(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerHabitatrelateWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerHabitatrelate: %v", err) - } -} - -func TestCreateFieldseekerInspectionsample(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerInspectionsampleWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerInspectionsample: %v", err) - } -} - -func TestCreateFieldseekerInspectionsampledetail(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerInspectionsampledetailWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerInspectionsampledetail: %v", err) - } -} - -func TestCreateFieldseekerLinelocation(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerLinelocationWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerLinelocation: %v", err) - } -} - -func TestCreateFieldseekerLocationtracking(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerLocationtrackingWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerLocationtracking: %v", err) - } -} - -func TestCreateFieldseekerMosquitoinspection(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerMosquitoinspectionWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerMosquitoinspection: %v", err) - } -} - -func TestCreateFieldseekerPointlocation(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerPointlocationWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerPointlocation: %v", err) - } -} - -func TestCreateFieldseekerPolygonlocation(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerPolygonlocationWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerPolygonlocation: %v", err) - } -} - -func TestCreateFieldseekerPool(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerPoolWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerPool: %v", err) - } -} - -func TestCreateFieldseekerPooldetail(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerPooldetailWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerPooldetail: %v", err) - } -} - -func TestCreateFieldseekerProposedtreatmentarea(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerProposedtreatmentareaWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerProposedtreatmentarea: %v", err) - } -} - -func TestCreateFieldseekerQamosquitoinspection(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerQamosquitoinspectionWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerQamosquitoinspection: %v", err) - } -} - -func TestCreateFieldseekerRodentlocation(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerRodentlocationWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerRodentlocation: %v", err) - } -} - -func TestCreateFieldseekerSamplecollection(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerSamplecollectionWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerSamplecollection: %v", err) - } -} - -func TestCreateFieldseekerSamplelocation(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerSamplelocationWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerSamplelocation: %v", err) - } -} - -func TestCreateFieldseekerServicerequest(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerServicerequestWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerServicerequest: %v", err) - } -} - -func TestCreateFieldseekerSpeciesabundance(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerSpeciesabundanceWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerSpeciesabundance: %v", err) - } -} - -func TestCreateFieldseekerStormdrain(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerStormdrainWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerStormdrain: %v", err) - } -} - -func TestCreateFieldseekerTimecard(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerTimecardWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerTimecard: %v", err) - } -} - -func TestCreateFieldseekerTrapdatum(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerTrapdatumWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerTrapdatum: %v", err) - } -} - -func TestCreateFieldseekerTraplocation(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerTraplocationWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerTraplocation: %v", err) - } -} - -func TestCreateFieldseekerTreatment(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerTreatmentWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerTreatment: %v", err) - } -} - -func TestCreateFieldseekerTreatmentarea(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerTreatmentareaWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerTreatmentarea: %v", err) - } -} - -func TestCreateFieldseekerZone(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerZoneWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerZone: %v", err) - } -} - -func TestCreateFieldseekerZones2(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerZones2WithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerZones2: %v", err) - } -} - -func TestCreateFieldseekerSync(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewFieldseekerSyncWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating FieldseekerSync: %v", err) - } -} - -func TestCreateGooseDBVersion(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewGooseDBVersionWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating GooseDBVersion: %v", err) - } -} - -func TestCreateH3Aggregation(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewH3AggregationWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating H3Aggregation: %v", err) - } -} - -func TestCreateNoteAudio(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewNoteAudioWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating NoteAudio: %v", err) - } -} - -func TestCreateNoteAudioBreadcrumb(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewNoteAudioBreadcrumbWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating NoteAudioBreadcrumb: %v", err) - } -} - -func TestCreateNoteAudioDatum(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewNoteAudioDatumWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating NoteAudioDatum: %v", err) - } -} - -func TestCreateNoteImage(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewNoteImageWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating NoteImage: %v", err) - } -} - -func TestCreateNoteImageBreadcrumb(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewNoteImageBreadcrumbWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating NoteImageBreadcrumb: %v", err) - } -} - -func TestCreateNoteImageDatum(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewNoteImageDatumWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating NoteImageDatum: %v", err) - } -} - -func TestCreateNotification(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewNotificationWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating Notification: %v", err) - } -} - -func TestCreateOauthToken(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewOauthTokenWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating OauthToken: %v", err) - } -} - -func TestCreateOrganization(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewOrganizationWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating Organization: %v", err) - } -} - -func TestCreatePublicreportQuick(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewPublicreportQuickWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating PublicreportQuick: %v", err) - } -} - -func TestCreatePublicreportQuickPhoto(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewPublicreportQuickPhotoWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating PublicreportQuickPhoto: %v", err) - } -} - -func TestCreateSession(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewSessionWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating Session: %v", err) - } -} - -func TestCreateSpatialRefSy(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewSpatialRefSyWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating SpatialRefSy: %v", err) - } -} - -func TestCreateUser(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctx, cancel := context.WithCancel(t.Context()) - t.Cleanup(cancel) - - tx, err := testDB.Begin(ctx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - if _, err := New().NewUserWithContext(ctx).Create(ctx, tx); err != nil { - t.Fatalf("Error creating User: %v", err) - } -} diff --git a/db/factory/bobfactory_random.bob_test.go b/db/factory/bobfactory_random.bob_test.go deleted file mode 100644 index 8cf573d9..00000000 --- a/db/factory/bobfactory_random.bob_test.go +++ /dev/null @@ -1,147 +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 factory - -import ( - "bytes" - "slices" - "testing" - - "github.com/stephenafamo/bob" -) - -// Set the testDB to enable tests that use the database -var testDB bob.Transactor[bob.Tx] - -func TestRandom___byte(t *testing.T) { - t.Parallel() - - val1 := random___byte(nil) - val2 := random___byte(nil) - - if bytes.Equal(val1, val2) { - t.Fatalf("random___byte() returned the same value twice: %v", val1) - } -} - -func TestRandom_float32(t *testing.T) { - t.Parallel() - - val1 := random_float32(nil) - val2 := random_float32(nil) - - if val1 == val2 { - t.Fatalf("random_float32() returned the same value twice: %v", val1) - } -} - -func TestRandom_float64(t *testing.T) { - t.Parallel() - - val1 := random_float64(nil) - val2 := random_float64(nil) - - if val1 == val2 { - t.Fatalf("random_float64() returned the same value twice: %v", val1) - } -} - -func TestRandom_int16(t *testing.T) { - t.Parallel() - - val1 := random_int16(nil) - val2 := random_int16(nil) - - if val1 == val2 { - t.Fatalf("random_int16() returned the same value twice: %v", val1) - } -} - -func TestRandom_int32(t *testing.T) { - t.Parallel() - - val1 := random_int32(nil) - val2 := random_int32(nil) - - if val1 == val2 { - t.Fatalf("random_int32() returned the same value twice: %v", val1) - } -} - -func TestRandom_int64(t *testing.T) { - t.Parallel() - - val1 := random_int64(nil) - val2 := random_int64(nil) - - if val1 == val2 { - t.Fatalf("random_int64() returned the same value twice: %v", val1) - } -} - -func TestRandom_pq_Float64Array(t *testing.T) { - t.Parallel() - - val1 := random_pq_Float64Array(nil) - val2 := random_pq_Float64Array(nil) - - if slices.Equal(val1, val2) { - t.Fatalf("random_pq_Float64Array() returned the same value twice: %v", val1) - } -} - -func TestRandom_pq_StringArray(t *testing.T) { - t.Parallel() - - val1 := random_pq_StringArray(nil) - val2 := random_pq_StringArray(nil) - - if slices.Equal(val1, val2) { - t.Fatalf("random_pq_StringArray() returned the same value twice: %v", val1) - } -} - -func TestRandom_string(t *testing.T) { - t.Parallel() - - val1 := random_string(nil) - val2 := random_string(nil) - - if val1 == val2 { - t.Fatalf("random_string() returned the same value twice: %v", val1) - } -} - -func TestRandom_time_Time(t *testing.T) { - t.Parallel() - - val1 := random_time_Time(nil) - val2 := random_time_Time(nil) - - if val1.Equal(val2) { - t.Fatalf("random_time_Time() returned the same value twice: %v", val1) - } -} - -func TestRandom_types_JSON_json_RawMessage_(t *testing.T) { - t.Parallel() - - val1 := random_types_JSON_json_RawMessage_(nil) - val2 := random_types_JSON_json_RawMessage_(nil) - - if bytes.Equal(val1.Val, val2.Val) { - t.Fatalf("random_types_JSON_json_RawMessage_() returned the same value twice: %v", val1) - } -} - -func TestRandom_uuid_UUID(t *testing.T) { - t.Parallel() - - val1 := random_uuid_UUID(nil) - val2 := random_uuid_UUID(nil) - - if val1 == val2 { - t.Fatalf("random_uuid_UUID() returned the same value twice: %v", val1) - } -} diff --git a/db/models/bob_types.bob_test.go b/db/models/bob_types.bob_test.go deleted file mode 100644 index 71e366b6..00000000 --- a/db/models/bob_types.bob_test.go +++ /dev/null @@ -1,223 +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 models - -import ( - "database/sql" - "database/sql/driver" - "encoding/json" - - enums "github.com/Gleipnir-Technology/nidus-sync/db/enums" - "github.com/google/uuid" - "github.com/lib/pq" - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/types" -) - -// Set the testDB to enable tests that use the database -var testDB bob.Transactor[bob.Tx] - -// Make sure the type FieldseekerContainerrelate runs hooks after queries -var _ bob.HookableType = &FieldseekerContainerrelate{} - -// Make sure the type FieldseekerFieldscoutinglog runs hooks after queries -var _ bob.HookableType = &FieldseekerFieldscoutinglog{} - -// Make sure the type FieldseekerHabitatrelate runs hooks after queries -var _ bob.HookableType = &FieldseekerHabitatrelate{} - -// Make sure the type FieldseekerInspectionsample runs hooks after queries -var _ bob.HookableType = &FieldseekerInspectionsample{} - -// Make sure the type FieldseekerInspectionsampledetail runs hooks after queries -var _ bob.HookableType = &FieldseekerInspectionsampledetail{} - -// Make sure the type FieldseekerLinelocation runs hooks after queries -var _ bob.HookableType = &FieldseekerLinelocation{} - -// Make sure the type FieldseekerLocationtracking runs hooks after queries -var _ bob.HookableType = &FieldseekerLocationtracking{} - -// Make sure the type FieldseekerMosquitoinspection runs hooks after queries -var _ bob.HookableType = &FieldseekerMosquitoinspection{} - -// Make sure the type FieldseekerPointlocation runs hooks after queries -var _ bob.HookableType = &FieldseekerPointlocation{} - -// Make sure the type FieldseekerPolygonlocation runs hooks after queries -var _ bob.HookableType = &FieldseekerPolygonlocation{} - -// Make sure the type FieldseekerPool runs hooks after queries -var _ bob.HookableType = &FieldseekerPool{} - -// Make sure the type FieldseekerPooldetail runs hooks after queries -var _ bob.HookableType = &FieldseekerPooldetail{} - -// Make sure the type FieldseekerProposedtreatmentarea runs hooks after queries -var _ bob.HookableType = &FieldseekerProposedtreatmentarea{} - -// Make sure the type FieldseekerQamosquitoinspection runs hooks after queries -var _ bob.HookableType = &FieldseekerQamosquitoinspection{} - -// Make sure the type FieldseekerRodentlocation runs hooks after queries -var _ bob.HookableType = &FieldseekerRodentlocation{} - -// Make sure the type FieldseekerSamplecollection runs hooks after queries -var _ bob.HookableType = &FieldseekerSamplecollection{} - -// Make sure the type FieldseekerSamplelocation runs hooks after queries -var _ bob.HookableType = &FieldseekerSamplelocation{} - -// Make sure the type FieldseekerServicerequest runs hooks after queries -var _ bob.HookableType = &FieldseekerServicerequest{} - -// Make sure the type FieldseekerSpeciesabundance runs hooks after queries -var _ bob.HookableType = &FieldseekerSpeciesabundance{} - -// Make sure the type FieldseekerStormdrain runs hooks after queries -var _ bob.HookableType = &FieldseekerStormdrain{} - -// Make sure the type FieldseekerTimecard runs hooks after queries -var _ bob.HookableType = &FieldseekerTimecard{} - -// Make sure the type FieldseekerTrapdatum runs hooks after queries -var _ bob.HookableType = &FieldseekerTrapdatum{} - -// Make sure the type FieldseekerTraplocation runs hooks after queries -var _ bob.HookableType = &FieldseekerTraplocation{} - -// Make sure the type FieldseekerTreatment runs hooks after queries -var _ bob.HookableType = &FieldseekerTreatment{} - -// Make sure the type FieldseekerTreatmentarea runs hooks after queries -var _ bob.HookableType = &FieldseekerTreatmentarea{} - -// Make sure the type FieldseekerZone runs hooks after queries -var _ bob.HookableType = &FieldseekerZone{} - -// Make sure the type FieldseekerZones2 runs hooks after queries -var _ bob.HookableType = &FieldseekerZones2{} - -// Make sure the type FieldseekerSync runs hooks after queries -var _ bob.HookableType = &FieldseekerSync{} - -// Make sure the type GeographyColumn runs hooks after queries -var _ bob.HookableType = &GeographyColumn{} - -// Make sure the type GeometryColumn runs hooks after queries -var _ bob.HookableType = &GeometryColumn{} - -// Make sure the type GooseDBVersion runs hooks after queries -var _ bob.HookableType = &GooseDBVersion{} - -// Make sure the type H3Aggregation runs hooks after queries -var _ bob.HookableType = &H3Aggregation{} - -// Make sure the type NoteAudio runs hooks after queries -var _ bob.HookableType = &NoteAudio{} - -// Make sure the type NoteAudioBreadcrumb runs hooks after queries -var _ bob.HookableType = &NoteAudioBreadcrumb{} - -// Make sure the type NoteAudioDatum runs hooks after queries -var _ bob.HookableType = &NoteAudioDatum{} - -// Make sure the type NoteImage runs hooks after queries -var _ bob.HookableType = &NoteImage{} - -// Make sure the type NoteImageBreadcrumb runs hooks after queries -var _ bob.HookableType = &NoteImageBreadcrumb{} - -// Make sure the type NoteImageDatum runs hooks after queries -var _ bob.HookableType = &NoteImageDatum{} - -// Make sure the type Notification runs hooks after queries -var _ bob.HookableType = &Notification{} - -// Make sure the type OauthToken runs hooks after queries -var _ bob.HookableType = &OauthToken{} - -// Make sure the type Organization runs hooks after queries -var _ bob.HookableType = &Organization{} - -// Make sure the type PublicreportQuick runs hooks after queries -var _ bob.HookableType = &PublicreportQuick{} - -// Make sure the type PublicreportQuickPhoto runs hooks after queries -var _ bob.HookableType = &PublicreportQuickPhoto{} - -// Make sure the type RasterColumn runs hooks after queries -var _ bob.HookableType = &RasterColumn{} - -// Make sure the type RasterOverview runs hooks after queries -var _ bob.HookableType = &RasterOverview{} - -// Make sure the type Session runs hooks after queries -var _ bob.HookableType = &Session{} - -// Make sure the type SpatialRefSy runs hooks after queries -var _ bob.HookableType = &SpatialRefSy{} - -// Make sure the type User runs hooks after queries -var _ bob.HookableType = &User{} - -// Make sure the type uuid.UUID satisfies database/sql.Scanner -var _ sql.Scanner = (*uuid.UUID)(nil) - -// Make sure the type uuid.UUID satisfies database/sql/driver.Valuer -var _ driver.Valuer = *new(uuid.UUID) - -// Make sure the type types.JSON[json.RawMessage] satisfies database/sql.Scanner -var _ sql.Scanner = (*types.JSON[json.RawMessage])(nil) - -// Make sure the type types.JSON[json.RawMessage] satisfies database/sql/driver.Valuer -var _ driver.Valuer = *new(types.JSON[json.RawMessage]) - -// Make sure the type enums.H3aggregationtype satisfies database/sql.Scanner -var _ sql.Scanner = (*enums.H3aggregationtype)(nil) - -// Make sure the type enums.H3aggregationtype satisfies database/sql/driver.Valuer -var _ driver.Valuer = *new(enums.H3aggregationtype) - -// Make sure the type enums.Audiodatatype satisfies database/sql.Scanner -var _ sql.Scanner = (*enums.Audiodatatype)(nil) - -// Make sure the type enums.Audiodatatype satisfies database/sql/driver.Valuer -var _ driver.Valuer = *new(enums.Audiodatatype) - -// Make sure the type enums.Notificationtype satisfies database/sql.Scanner -var _ sql.Scanner = (*enums.Notificationtype)(nil) - -// Make sure the type enums.Notificationtype satisfies database/sql/driver.Valuer -var _ driver.Valuer = *new(enums.Notificationtype) - -// Make sure the type pq.StringArray satisfies database/sql.Scanner -var _ sql.Scanner = (*pq.StringArray)(nil) - -// Make sure the type pq.StringArray satisfies database/sql/driver.Valuer -var _ driver.Valuer = *new(pq.StringArray) - -// Make sure the type pq.Float64Array satisfies database/sql.Scanner -var _ sql.Scanner = (*pq.Float64Array)(nil) - -// Make sure the type pq.Float64Array satisfies database/sql/driver.Valuer -var _ driver.Valuer = *new(pq.Float64Array) - -// Make sure the type pq.BoolArray satisfies database/sql.Scanner -var _ sql.Scanner = (*pq.BoolArray)(nil) - -// Make sure the type pq.BoolArray satisfies database/sql/driver.Valuer -var _ driver.Valuer = *new(pq.BoolArray) - -// Make sure the type enums.Arcgislicensetype satisfies database/sql.Scanner -var _ sql.Scanner = (*enums.Arcgislicensetype)(nil) - -// Make sure the type enums.Arcgislicensetype satisfies database/sql/driver.Valuer -var _ driver.Valuer = *new(enums.Arcgislicensetype) - -// Make sure the type enums.Hashtype satisfies database/sql.Scanner -var _ sql.Scanner = (*enums.Hashtype)(nil) - -// Make sure the type enums.Hashtype satisfies database/sql/driver.Valuer -var _ driver.Valuer = *new(enums.Hashtype) diff --git a/db/sql/oauth_by_user_id.bob_test.go b/db/sql/oauth_by_user_id.bob_test.go deleted file mode 100644 index d23dae74..00000000 --- a/db/sql/oauth_by_user_id.bob_test.go +++ /dev/null @@ -1,131 +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 sql - -import ( - "context" - "fmt" - "strings" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - testutils "github.com/stephenafamo/bob/test/utils" -) - -func TestOauthTokenByUserId(t *testing.T) { - t.Run("Base", func(t *testing.T) { - var sb strings.Builder - - query := OauthTokenByUserId(random_int32(nil)) - - if _, err := query.WriteQuery(t.Context(), &sb, 1); err != nil { - t.Fatal(err) - } - - if diff := cmp.Diff(oauthTokenByUserIdSQL, sb.String()); diff != "" { - t.Fatalf("unexpected result (-got +want):\n%s", diff) - } - }) - - t.Run("Mod", func(t *testing.T) { - var sb strings.Builder - - query := OauthTokenByUserId(random_int32(nil)) - - if _, err := psql.Select(query).WriteQuery(t.Context(), &sb, 1); err != nil { - t.Fatal(err) - } - - queryDiff, err := testutils.QueryDiff(oauthTokenByUserIdSQL, sb.String(), formatQuery) - if err != nil { - t.Fatal(err) - } - if queryDiff != "" { - fmt.Println(sb.String()) - t.Fatalf("unexpected result (-got +want):\n%s", queryDiff) - } - }) - - t.Run("Scanning", func(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctxTx, cancel := context.WithCancel(t.Context()) - defer cancel() - - tx, err := testDB.Begin(ctxTx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctxTx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - query, args, err := bob.Build(ctxTx, psql.Select(OauthTokenByUserId(random_int32(nil)))) - if err != nil { - t.Fatal(err) - } - - rows, err := tx.QueryContext(ctxTx, query, args...) - if err != nil { - t.Fatal(err) - } - defer rows.Close() - - columns, err := rows.Columns() - if err != nil { - t.Fatal(err) - } - - if len(columns) != 10 { - t.Fatalf("expected %d columns, got %d", 10, len(columns)) - } - - if columns[0] != "id" { - t.Fatalf("expected column %d to be %s, got %s", 0, "id", columns[0]) - } - - if columns[1] != "access_token" { - t.Fatalf("expected column %d to be %s, got %s", 1, "access_token", columns[1]) - } - - if columns[2] != "access_token_expires" { - t.Fatalf("expected column %d to be %s, got %s", 2, "access_token_expires", columns[2]) - } - - if columns[3] != "refresh_token" { - t.Fatalf("expected column %d to be %s, got %s", 3, "refresh_token", columns[3]) - } - - if columns[4] != "username" { - t.Fatalf("expected column %d to be %s, got %s", 4, "username", columns[4]) - } - - if columns[5] != "user_id" { - t.Fatalf("expected column %d to be %s, got %s", 5, "user_id", columns[5]) - } - - if columns[6] != "arcgis_id" { - t.Fatalf("expected column %d to be %s, got %s", 6, "arcgis_id", columns[6]) - } - - if columns[7] != "arcgis_license_type_id" { - t.Fatalf("expected column %d to be %s, got %s", 7, "arcgis_license_type_id", columns[7]) - } - - if columns[8] != "refresh_token_expires" { - t.Fatalf("expected column %d to be %s, got %s", 8, "refresh_token_expires", columns[8]) - } - - if columns[9] != "invalidated_at" { - t.Fatalf("expected column %d to be %s, got %s", 9, "invalidated_at", columns[9]) - } - }) -} diff --git a/db/sql/org_by_oauth_id.bob_test.go b/db/sql/org_by_oauth_id.bob_test.go deleted file mode 100644 index 2c7b02c0..00000000 --- a/db/sql/org_by_oauth_id.bob_test.go +++ /dev/null @@ -1,103 +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 sql - -import ( - "context" - "fmt" - "strings" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - testutils "github.com/stephenafamo/bob/test/utils" -) - -func TestOrgByOauthId(t *testing.T) { - t.Run("Base", func(t *testing.T) { - var sb strings.Builder - - query := OrgByOauthId(random_int32(nil)) - - if _, err := query.WriteQuery(t.Context(), &sb, 1); err != nil { - t.Fatal(err) - } - - if diff := cmp.Diff(orgByOauthIdSQL, sb.String()); diff != "" { - t.Fatalf("unexpected result (-got +want):\n%s", diff) - } - }) - - t.Run("Mod", func(t *testing.T) { - var sb strings.Builder - - query := OrgByOauthId(random_int32(nil)) - - if _, err := psql.Select(query).WriteQuery(t.Context(), &sb, 1); err != nil { - t.Fatal(err) - } - - queryDiff, err := testutils.QueryDiff(orgByOauthIdSQL, sb.String(), formatQuery) - if err != nil { - t.Fatal(err) - } - if queryDiff != "" { - fmt.Println(sb.String()) - t.Fatalf("unexpected result (-got +want):\n%s", queryDiff) - } - }) - - t.Run("Scanning", func(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctxTx, cancel := context.WithCancel(t.Context()) - defer cancel() - - tx, err := testDB.Begin(ctxTx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctxTx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - query, args, err := bob.Build(ctxTx, psql.Select(OrgByOauthId(random_int32(nil)))) - if err != nil { - t.Fatal(err) - } - - rows, err := tx.QueryContext(ctxTx, query, args...) - if err != nil { - t.Fatal(err) - } - defer rows.Close() - - columns, err := rows.Columns() - if err != nil { - t.Fatal(err) - } - - if len(columns) != 3 { - t.Fatalf("expected %d columns, got %d", 3, len(columns)) - } - - if columns[0] != "organization_id" { - t.Fatalf("expected column %d to be %s, got %s", 0, "organization_id", columns[0]) - } - - if columns[1] != "arcgis_id" { - t.Fatalf("expected column %d to be %s, got %s", 1, "arcgis_id", columns[1]) - } - - if columns[2] != "fieldseeker_url" { - t.Fatalf("expected column %d to be %s, got %s", 2, "fieldseeker_url", columns[2]) - } - }) -} diff --git a/db/sql/test_utils.bob_test.go b/db/sql/test_utils.bob_test.go deleted file mode 100644 index 5d99a660..00000000 --- a/db/sql/test_utils.bob_test.go +++ /dev/null @@ -1,101 +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 sql - -import ( - "strconv" - "strings" - "time" - - enums "github.com/Gleipnir-Technology/nidus-sync/db/enums" - "github.com/google/uuid" - "github.com/jaswdr/faker/v2" - "github.com/stephenafamo/bob" - pg_query "github.com/wasilibs/go-pgquery" -) - -// Set the testDB to enable tests that use the database -var testDB bob.Transactor[bob.Tx] - -func formatQuery(s string) (string, error) { - aTree, err := pg_query.Parse(s) - if err != nil { - return "", err - } - - return pg_query.Deparse(aTree) -} - -var defaultFaker = faker.New() - -func random_enums_Arcgislicensetype(f *faker.Faker, limits ...string) enums.Arcgislicensetype { - if f == nil { - f = &defaultFaker - } - - var e enums.Arcgislicensetype - all := e.All() - return all[f.IntBetween(0, len(all)-1)] -} - -func random_enums_Hashtype(f *faker.Faker, limits ...string) enums.Hashtype { - if f == nil { - f = &defaultFaker - } - - var e enums.Hashtype - all := e.All() - return all[f.IntBetween(0, len(all)-1)] -} - -func random_int32(f *faker.Faker, limits ...string) int32 { - if f == nil { - f = &defaultFaker - } - - return f.Int32() -} - -func random_int64(f *faker.Faker, limits ...string) int64 { - if f == nil { - f = &defaultFaker - } - - return f.Int64() -} - -func random_string(f *faker.Faker, limits ...string) string { - if f == nil { - f = &defaultFaker - } - - val := strings.Join(f.Lorem().Words(f.IntBetween(1, 5)), " ") - if len(limits) == 0 { - return val - } - limitInt, _ := strconv.Atoi(limits[0]) - if limitInt > 0 && limitInt < len(val) { - val = val[:limitInt] - } - return val -} - -func random_time_Time(f *faker.Faker, limits ...string) time.Time { - if f == nil { - f = &defaultFaker - } - - year := time.Hour * 24 * 365 - min := time.Now().Add(-year) - max := time.Now().Add(year) - return f.Time().TimeBetween(min, max) -} - -func random_uuid_UUID(f *faker.Faker, limits ...string) uuid.UUID { - if f == nil { - f = &defaultFaker - } - - return uuid.New() -} diff --git a/db/sql/traplocation_by_source_id.bob_test.go b/db/sql/traplocation_by_source_id.bob_test.go deleted file mode 100644 index fbbf80ea..00000000 --- a/db/sql/traplocation_by_source_id.bob_test.go +++ /dev/null @@ -1,99 +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 sql - -import ( - "context" - "fmt" - "strings" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - testutils "github.com/stephenafamo/bob/test/utils" -) - -func TestTrapLocationBySourceID(t *testing.T) { - t.Run("Base", func(t *testing.T) { - var sb strings.Builder - - query := TrapLocationBySourceID(random_int32(nil), random_uuid_UUID(nil)) - - if _, err := query.WriteQuery(t.Context(), &sb, 1); err != nil { - t.Fatal(err) - } - - if diff := cmp.Diff(trapLocationBySourceIDSQL, sb.String()); diff != "" { - t.Fatalf("unexpected result (-got +want):\n%s", diff) - } - }) - - t.Run("Mod", func(t *testing.T) { - var sb strings.Builder - - query := TrapLocationBySourceID(random_int32(nil), random_uuid_UUID(nil)) - - if _, err := psql.Select(query).WriteQuery(t.Context(), &sb, 1); err != nil { - t.Fatal(err) - } - - queryDiff, err := testutils.QueryDiff(trapLocationBySourceIDSQL, sb.String(), formatQuery) - if err != nil { - t.Fatal(err) - } - if queryDiff != "" { - fmt.Println(sb.String()) - t.Fatalf("unexpected result (-got +want):\n%s", queryDiff) - } - }) - - t.Run("Scanning", func(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctxTx, cancel := context.WithCancel(t.Context()) - defer cancel() - - tx, err := testDB.Begin(ctxTx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctxTx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - query, args, err := bob.Build(ctxTx, psql.Select(TrapLocationBySourceID(random_int32(nil), random_uuid_UUID(nil)))) - if err != nil { - t.Fatal(err) - } - - rows, err := tx.QueryContext(ctxTx, query, args...) - if err != nil { - t.Fatal(err) - } - defer rows.Close() - - columns, err := rows.Columns() - if err != nil { - t.Fatal(err) - } - - if len(columns) != 2 { - t.Fatalf("expected %d columns, got %d", 2, len(columns)) - } - - if columns[0] != "trap_location_globalid" { - t.Fatalf("expected column %d to be %s, got %s", 0, "trap_location_globalid", columns[0]) - } - - if columns[1] != "distance" { - t.Fatalf("expected column %d to be %s, got %s", 1, "distance", columns[1]) - } - }) -} diff --git a/db/sql/update_oauth_org.bob_test.go b/db/sql/update_oauth_org.bob_test.go deleted file mode 100644 index d737e792..00000000 --- a/db/sql/update_oauth_org.bob_test.go +++ /dev/null @@ -1,76 +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 sql - -import ( - "context" - "fmt" - "strings" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - testutils "github.com/stephenafamo/bob/test/utils" -) - -func TestUpdateOauthTokenOrg(t *testing.T) { - t.Run("Base", func(t *testing.T) { - var sb strings.Builder - - query := UpdateOauthTokenOrg(random_string(nil), random_string(nil), random_string(nil)) - - if _, err := query.WriteQuery(t.Context(), &sb, 1); err != nil { - t.Fatal(err) - } - - if diff := cmp.Diff(updateOauthTokenOrgSQL, sb.String()); diff != "" { - t.Fatalf("unexpected result (-got +want):\n%s", diff) - } - }) - - t.Run("Mod", func(t *testing.T) { - var sb strings.Builder - - query := UpdateOauthTokenOrg(random_string(nil), random_string(nil), random_string(nil)) - - if _, err := psql.Update(query).WriteQuery(t.Context(), &sb, 1); err != nil { - t.Fatal(err) - } - - queryDiff, err := testutils.QueryDiff(updateOauthTokenOrgSQL, sb.String(), formatQuery) - if err != nil { - t.Fatal(err) - } - if queryDiff != "" { - fmt.Println(sb.String()) - t.Fatalf("unexpected result (-got +want):\n%s", queryDiff) - } - }) - - t.Run("Exec", func(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctxTx, cancel := context.WithCancel(t.Context()) - defer cancel() - - tx, err := testDB.Begin(ctxTx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctxTx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - query := psql.Update(UpdateOauthTokenOrg(random_string(nil), random_string(nil), random_string(nil))) - if _, err := bob.Exec(ctxTx, tx, query); err != nil { - t.Fatal(err) - } - }) -} diff --git a/db/sql/user_by_username.bob_test.go b/db/sql/user_by_username.bob_test.go deleted file mode 100644 index 20bb24f3..00000000 --- a/db/sql/user_by_username.bob_test.go +++ /dev/null @@ -1,139 +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 sql - -import ( - "context" - "fmt" - "strings" - "testing" - - "github.com/google/go-cmp/cmp" - "github.com/stephenafamo/bob" - "github.com/stephenafamo/bob/dialect/psql" - testutils "github.com/stephenafamo/bob/test/utils" -) - -func TestUserByUsername(t *testing.T) { - t.Run("Base", func(t *testing.T) { - var sb strings.Builder - - query := UserByUsername(random_string(nil)) - - if _, err := query.WriteQuery(t.Context(), &sb, 1); err != nil { - t.Fatal(err) - } - - if diff := cmp.Diff(userByUsernameSQL, sb.String()); diff != "" { - t.Fatalf("unexpected result (-got +want):\n%s", diff) - } - }) - - t.Run("Mod", func(t *testing.T) { - var sb strings.Builder - - query := UserByUsername(random_string(nil)) - - if _, err := psql.Select(query).WriteQuery(t.Context(), &sb, 1); err != nil { - t.Fatal(err) - } - - queryDiff, err := testutils.QueryDiff(userByUsernameSQL, sb.String(), formatQuery) - if err != nil { - t.Fatal(err) - } - if queryDiff != "" { - fmt.Println(sb.String()) - t.Fatalf("unexpected result (-got +want):\n%s", queryDiff) - } - }) - - t.Run("Scanning", func(t *testing.T) { - if testDB == nil { - t.Skip("skipping test, no DSN provided") - } - - ctxTx, cancel := context.WithCancel(t.Context()) - defer cancel() - - tx, err := testDB.Begin(ctxTx) - if err != nil { - t.Fatalf("Error starting transaction: %v", err) - } - - defer func() { - if err := tx.Rollback(ctxTx); err != nil { - t.Fatalf("Error rolling back transaction: %v", err) - } - }() - - query, args, err := bob.Build(ctxTx, psql.Select(UserByUsername(random_string(nil)))) - if err != nil { - t.Fatal(err) - } - - rows, err := tx.QueryContext(ctxTx, query, args...) - if err != nil { - t.Fatal(err) - } - defer rows.Close() - - columns, err := rows.Columns() - if err != nil { - t.Fatal(err) - } - - if len(columns) != 12 { - t.Fatalf("expected %d columns, got %d", 12, len(columns)) - } - - if columns[0] != "id" { - t.Fatalf("expected column %d to be %s, got %s", 0, "id", columns[0]) - } - - if columns[1] != "arcgis_access_token" { - t.Fatalf("expected column %d to be %s, got %s", 1, "arcgis_access_token", columns[1]) - } - - if columns[2] != "arcgis_license" { - t.Fatalf("expected column %d to be %s, got %s", 2, "arcgis_license", columns[2]) - } - - if columns[3] != "arcgis_refresh_token" { - t.Fatalf("expected column %d to be %s, got %s", 3, "arcgis_refresh_token", columns[3]) - } - - if columns[4] != "arcgis_refresh_token_expires" { - t.Fatalf("expected column %d to be %s, got %s", 4, "arcgis_refresh_token_expires", columns[4]) - } - - if columns[5] != "arcgis_role" { - t.Fatalf("expected column %d to be %s, got %s", 5, "arcgis_role", columns[5]) - } - - if columns[6] != "display_name" { - t.Fatalf("expected column %d to be %s, got %s", 6, "display_name", columns[6]) - } - - if columns[7] != "email" { - t.Fatalf("expected column %d to be %s, got %s", 7, "email", columns[7]) - } - - if columns[8] != "organization_id" { - t.Fatalf("expected column %d to be %s, got %s", 8, "organization_id", columns[8]) - } - - if columns[9] != "username" { - t.Fatalf("expected column %d to be %s, got %s", 9, "username", columns[9]) - } - - if columns[10] != "password_hash_type" { - t.Fatalf("expected column %d to be %s, got %s", 10, "password_hash_type", columns[10]) - } - - if columns[11] != "password_hash" { - t.Fatalf("expected column %d to be %s, got %s", 11, "password_hash", columns[11]) - } - }) -}