mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 23:16:45 +00:00
Withdraw additional functionality (validation/submission/tracking) (#409)
* reworked request struct and exchange response started work on validation system * removed import cycle until work around * Added intial withdraw support via CLI added * Added Crypto command to gctcli * moved var declartion to single line * Test updates for binance and anx * All exchange tests have been updated test coverage added to validate * First pass at adding withdrawl select from database * started adding basic lru cache system * Added basic LRU cache including Add Get Remove Contains ContainsOrAdd Clear * wording changes on comments * removed exported var's in strut as they are not required * Added README * README updates * corrected ID on commands * rm line :D * merged in origin/cache * linter fixes (gofmt) * Added basic cache lookup to events * swapped to mutex over rwmutex updated comments * unexported getNewest & getOldest * unexported getNewest & getOldest * Updated comments and cited references in source * updated comments * WIP * Migrated exchange WithdrawFiat wrapper to new struct response * Migrated exchange WithdrawFiat wrapper to new struct response * started work on bank management * Added exchange level banking details back with migration to banking package * Removed broken tests for now * Added validation to bank accounts * removed duplicate bank details from withdraw struct * Test coverage increased * gofmt * merged upstream/master with clean up * First pass at adding command line linking to gctcli * added validation for crypto address, added gctcli support to retreive previous withdrawal requests * general cleanup * general cleanup * reordered imports * Increased test coverage moved to database sublogger * Pass incorrect currency no longer return error from c.CheckBankAccountConfig * remove TestMain() for now as other tests in this package will need to be reworked * Happy little race car * Reverted to upstream tests * Added test covarege for validation method, corrected response on cli protobuf * query clean up and removal of duplicated code * cleaned up queries into singlem ethod increased test coverage * Migrated international fund withdraw to new exchange response and added cache size override * Migrated international fund withdraw to new exchange response and added cache size override * Extended gctcli commands * lowered default cache to 25 * small code clean up * added get by date method * add returned error * cli commands cleaing return error on nil results to fix out of bounds * merged write & read helpers into one for test coverage and increased engine/withdraw test coverage * gofmt * Added test coverage for valid ID * removed unused param * converted to use timestamp package from protobuf * gofmt * use built in RFC3339 timestamp * remove setting of CreatedAt & UpdatedAt and allow ORm to take care of it * also use ptype on byid * code flow improvements * remove inverse conditional check and linters run * removed test data * removed comment * removed comment * also write failures to database for auditing * converted to use default time for start & end * Default to time.Now() minus 30 days * Default to time.Now() minus 30 days * small code clean up * fixed missing semicolon on migrations, code clean up * updated sqlite migrations * Added additonal check for exchange level bank account if global is not found * case sensativity fix for currency names * use correct compare * test coverage fixed * removed space * return pointer to banking.Account * return pointer to banking.Account * added else check back to validate() * Added empty string as default to migration over NULL due to retrivial of data
This commit is contained in:
@@ -14,56 +14,67 @@ import "testing"
|
||||
func TestParent(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEvents)
|
||||
t.Run("Scripts", testScripts)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistories)
|
||||
}
|
||||
|
||||
func TestDelete(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsDelete)
|
||||
t.Run("Scripts", testScriptsDelete)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesDelete)
|
||||
}
|
||||
|
||||
func TestQueryDeleteAll(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsQueryDeleteAll)
|
||||
t.Run("Scripts", testScriptsQueryDeleteAll)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesQueryDeleteAll)
|
||||
}
|
||||
|
||||
func TestSliceDeleteAll(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsSliceDeleteAll)
|
||||
t.Run("Scripts", testScriptsSliceDeleteAll)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesSliceDeleteAll)
|
||||
}
|
||||
|
||||
func TestExists(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsExists)
|
||||
t.Run("Scripts", testScriptsExists)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesExists)
|
||||
}
|
||||
|
||||
func TestFind(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsFind)
|
||||
t.Run("Scripts", testScriptsFind)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesFind)
|
||||
}
|
||||
|
||||
func TestBind(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsBind)
|
||||
t.Run("Scripts", testScriptsBind)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesBind)
|
||||
}
|
||||
|
||||
func TestOne(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsOne)
|
||||
t.Run("Scripts", testScriptsOne)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesOne)
|
||||
}
|
||||
|
||||
func TestAll(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsAll)
|
||||
t.Run("Scripts", testScriptsAll)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesAll)
|
||||
}
|
||||
|
||||
func TestCount(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsCount)
|
||||
t.Run("Scripts", testScriptsCount)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesCount)
|
||||
}
|
||||
|
||||
func TestHooks(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsHooks)
|
||||
t.Run("Scripts", testScriptsHooks)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesHooks)
|
||||
}
|
||||
|
||||
func TestInsert(t *testing.T) {
|
||||
@@ -71,6 +82,8 @@ func TestInsert(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsInsertWhitelist)
|
||||
t.Run("Scripts", testScriptsInsert)
|
||||
t.Run("Scripts", testScriptsInsertWhitelist)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesInsert)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesInsertWhitelist)
|
||||
}
|
||||
|
||||
// TestToOne tests cannot be run in parallel
|
||||
@@ -116,24 +129,29 @@ func TestToManyRemove(t *testing.T) {}
|
||||
func TestReload(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsReload)
|
||||
t.Run("Scripts", testScriptsReload)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesReload)
|
||||
}
|
||||
|
||||
func TestReloadAll(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsReloadAll)
|
||||
t.Run("Scripts", testScriptsReloadAll)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesReloadAll)
|
||||
}
|
||||
|
||||
func TestSelect(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsSelect)
|
||||
t.Run("Scripts", testScriptsSelect)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesSelect)
|
||||
}
|
||||
|
||||
func TestUpdate(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsUpdate)
|
||||
t.Run("Scripts", testScriptsUpdate)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesUpdate)
|
||||
}
|
||||
|
||||
func TestSliceUpdateAll(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsSliceUpdateAll)
|
||||
t.Run("Scripts", testScriptsSliceUpdateAll)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesSliceUpdateAll)
|
||||
}
|
||||
|
||||
@@ -4,11 +4,17 @@
|
||||
package postgres
|
||||
|
||||
var TableNames = struct {
|
||||
AuditEvent string
|
||||
Script string
|
||||
ScriptExecution string
|
||||
AuditEvent string
|
||||
Script string
|
||||
ScriptExecution string
|
||||
WithdrawalCrypto string
|
||||
WithdrawalFiat string
|
||||
WithdrawalHistory string
|
||||
}{
|
||||
AuditEvent: "audit_event",
|
||||
Script: "script",
|
||||
ScriptExecution: "script_execution",
|
||||
AuditEvent: "audit_event",
|
||||
Script: "script",
|
||||
ScriptExecution: "script_execution",
|
||||
WithdrawalCrypto: "withdrawal_crypto",
|
||||
WithdrawalFiat: "withdrawal_fiat",
|
||||
WithdrawalHistory: "withdrawal_history",
|
||||
}
|
||||
|
||||
@@ -8,4 +8,5 @@ import "testing"
|
||||
func TestUpsert(t *testing.T) {
|
||||
t.Run("AuditEvents", testAuditEventsUpsert)
|
||||
t.Run("Scripts", testScriptsUpsert)
|
||||
t.Run("WithdrawalHistories", testWithdrawalHistoriesUpsert)
|
||||
}
|
||||
|
||||
1096
database/models/postgres/withdrawal_crypto.go
Normal file
1096
database/models/postgres/withdrawal_crypto.go
Normal file
File diff suppressed because it is too large
Load Diff
892
database/models/postgres/withdrawal_crypto_test.go
Normal file
892
database/models/postgres/withdrawal_crypto_test.go
Normal file
@@ -0,0 +1,892 @@
|
||||
// Code generated by SQLBoiler 3.5.0-gct (https://github.com/thrasher-corp/sqlboiler). DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/thrasher-corp/sqlboiler/boil"
|
||||
"github.com/thrasher-corp/sqlboiler/queries"
|
||||
"github.com/thrasher-corp/sqlboiler/randomize"
|
||||
"github.com/thrasher-corp/sqlboiler/strmangle"
|
||||
)
|
||||
|
||||
var (
|
||||
// Relationships sometimes use the reflection helper queries.Equal/queries.Assign
|
||||
// so force a package dependency in case they don't.
|
||||
_ = queries.Equal
|
||||
)
|
||||
|
||||
func testWithdrawalCryptos(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
query := WithdrawalCryptos()
|
||||
|
||||
if query.Query == nil {
|
||||
t.Error("expected a query, got nothing")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosDelete(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rowsAff, err := o.Delete(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
} else if rowsAff != 1 {
|
||||
t.Error("should only have deleted one row, but affected:", rowsAff)
|
||||
}
|
||||
|
||||
count, err := WithdrawalCryptos().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 0 {
|
||||
t.Error("want zero records, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosQueryDeleteAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rowsAff, err := WithdrawalCryptos().DeleteAll(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
} else if rowsAff != 1 {
|
||||
t.Error("should only have deleted one row, but affected:", rowsAff)
|
||||
}
|
||||
|
||||
count, err := WithdrawalCryptos().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 0 {
|
||||
t.Error("want zero records, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosSliceDeleteAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
slice := WithdrawalCryptoSlice{o}
|
||||
|
||||
if rowsAff, err := slice.DeleteAll(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
} else if rowsAff != 1 {
|
||||
t.Error("should only have deleted one row, but affected:", rowsAff)
|
||||
}
|
||||
|
||||
count, err := WithdrawalCryptos().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 0 {
|
||||
t.Error("want zero records, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosExists(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
e, err := WithdrawalCryptoExists(ctx, tx, o.ID)
|
||||
if err != nil {
|
||||
t.Errorf("Unable to check if WithdrawalCrypto exists: %s", err)
|
||||
}
|
||||
if !e {
|
||||
t.Errorf("Expected WithdrawalCryptoExists to return true, but got false.")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosFind(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
withdrawalCryptoFound, err := FindWithdrawalCrypto(ctx, tx, o.ID)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if withdrawalCryptoFound == nil {
|
||||
t.Error("want a record, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosBind(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if err = WithdrawalCryptos().Bind(ctx, tx, o); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosOne(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if x, err := WithdrawalCryptos().One(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
} else if x == nil {
|
||||
t.Error("expected to get a non nil record")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
withdrawalCryptoOne := &WithdrawalCrypto{}
|
||||
withdrawalCryptoTwo := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, withdrawalCryptoOne, withdrawalCryptoDBTypes, false, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
if err = randomize.Struct(seed, withdrawalCryptoTwo, withdrawalCryptoDBTypes, false, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = withdrawalCryptoOne.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err = withdrawalCryptoTwo.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
slice, err := WithdrawalCryptos().All(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if len(slice) != 2 {
|
||||
t.Error("want 2 records, got:", len(slice))
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosCount(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var err error
|
||||
seed := randomize.NewSeed()
|
||||
withdrawalCryptoOne := &WithdrawalCrypto{}
|
||||
withdrawalCryptoTwo := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, withdrawalCryptoOne, withdrawalCryptoDBTypes, false, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
if err = randomize.Struct(seed, withdrawalCryptoTwo, withdrawalCryptoDBTypes, false, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = withdrawalCryptoOne.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err = withdrawalCryptoTwo.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalCryptos().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 2 {
|
||||
t.Error("want 2 records, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func withdrawalCryptoBeforeInsertHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalCrypto) error {
|
||||
*o = WithdrawalCrypto{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalCryptoAfterInsertHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalCrypto) error {
|
||||
*o = WithdrawalCrypto{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalCryptoAfterSelectHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalCrypto) error {
|
||||
*o = WithdrawalCrypto{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalCryptoBeforeUpdateHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalCrypto) error {
|
||||
*o = WithdrawalCrypto{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalCryptoAfterUpdateHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalCrypto) error {
|
||||
*o = WithdrawalCrypto{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalCryptoBeforeDeleteHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalCrypto) error {
|
||||
*o = WithdrawalCrypto{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalCryptoAfterDeleteHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalCrypto) error {
|
||||
*o = WithdrawalCrypto{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalCryptoBeforeUpsertHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalCrypto) error {
|
||||
*o = WithdrawalCrypto{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalCryptoAfterUpsertHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalCrypto) error {
|
||||
*o = WithdrawalCrypto{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosHooks(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var err error
|
||||
|
||||
ctx := context.Background()
|
||||
empty := &WithdrawalCrypto{}
|
||||
o := &WithdrawalCrypto{}
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, false); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto object: %s", err)
|
||||
}
|
||||
|
||||
AddWithdrawalCryptoHook(boil.BeforeInsertHook, withdrawalCryptoBeforeInsertHook)
|
||||
if err = o.doBeforeInsertHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doBeforeInsertHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected BeforeInsertHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalCryptoBeforeInsertHooks = []WithdrawalCryptoHook{}
|
||||
|
||||
AddWithdrawalCryptoHook(boil.AfterInsertHook, withdrawalCryptoAfterInsertHook)
|
||||
if err = o.doAfterInsertHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doAfterInsertHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected AfterInsertHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalCryptoAfterInsertHooks = []WithdrawalCryptoHook{}
|
||||
|
||||
AddWithdrawalCryptoHook(boil.AfterSelectHook, withdrawalCryptoAfterSelectHook)
|
||||
if err = o.doAfterSelectHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doAfterSelectHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected AfterSelectHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalCryptoAfterSelectHooks = []WithdrawalCryptoHook{}
|
||||
|
||||
AddWithdrawalCryptoHook(boil.BeforeUpdateHook, withdrawalCryptoBeforeUpdateHook)
|
||||
if err = o.doBeforeUpdateHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doBeforeUpdateHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected BeforeUpdateHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalCryptoBeforeUpdateHooks = []WithdrawalCryptoHook{}
|
||||
|
||||
AddWithdrawalCryptoHook(boil.AfterUpdateHook, withdrawalCryptoAfterUpdateHook)
|
||||
if err = o.doAfterUpdateHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doAfterUpdateHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected AfterUpdateHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalCryptoAfterUpdateHooks = []WithdrawalCryptoHook{}
|
||||
|
||||
AddWithdrawalCryptoHook(boil.BeforeDeleteHook, withdrawalCryptoBeforeDeleteHook)
|
||||
if err = o.doBeforeDeleteHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doBeforeDeleteHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected BeforeDeleteHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalCryptoBeforeDeleteHooks = []WithdrawalCryptoHook{}
|
||||
|
||||
AddWithdrawalCryptoHook(boil.AfterDeleteHook, withdrawalCryptoAfterDeleteHook)
|
||||
if err = o.doAfterDeleteHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doAfterDeleteHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected AfterDeleteHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalCryptoAfterDeleteHooks = []WithdrawalCryptoHook{}
|
||||
|
||||
AddWithdrawalCryptoHook(boil.BeforeUpsertHook, withdrawalCryptoBeforeUpsertHook)
|
||||
if err = o.doBeforeUpsertHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doBeforeUpsertHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected BeforeUpsertHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalCryptoBeforeUpsertHooks = []WithdrawalCryptoHook{}
|
||||
|
||||
AddWithdrawalCryptoHook(boil.AfterUpsertHook, withdrawalCryptoAfterUpsertHook)
|
||||
if err = o.doAfterUpsertHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doAfterUpsertHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected AfterUpsertHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalCryptoAfterUpsertHooks = []WithdrawalCryptoHook{}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosInsert(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalCryptos().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosInsertWhitelist(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Whitelist(withdrawalCryptoColumnsWithoutDefault...)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalCryptos().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptoToOneWithdrawalHistoryUsingWithdrawalCrypto(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
var local WithdrawalCrypto
|
||||
var foreign WithdrawalHistory
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
if err := randomize.Struct(seed, &local, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
if err := randomize.Struct(seed, &foreign, withdrawalHistoryDBTypes, false, withdrawalHistoryColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalHistory struct: %s", err)
|
||||
}
|
||||
|
||||
if err := foreign.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
queries.Assign(&local.WithdrawalCryptoID, foreign.ID)
|
||||
if err := local.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
check, err := local.WithdrawalCrypto().One(ctx, tx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !queries.Equal(check.ID, foreign.ID) {
|
||||
t.Errorf("want: %v, got %v", foreign.ID, check.ID)
|
||||
}
|
||||
|
||||
slice := WithdrawalCryptoSlice{&local}
|
||||
if err = local.L.LoadWithdrawalCrypto(ctx, tx, false, (*[]*WithdrawalCrypto)(&slice), nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if local.R.WithdrawalCrypto == nil {
|
||||
t.Error("struct should have been eager loaded")
|
||||
}
|
||||
|
||||
local.R.WithdrawalCrypto = nil
|
||||
if err = local.L.LoadWithdrawalCrypto(ctx, tx, true, &local, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if local.R.WithdrawalCrypto == nil {
|
||||
t.Error("struct should have been eager loaded")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptoToOneSetOpWithdrawalHistoryUsingWithdrawalCrypto(t *testing.T) {
|
||||
var err error
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
var a WithdrawalCrypto
|
||||
var b, c WithdrawalHistory
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
if err = randomize.Struct(seed, &a, withdrawalCryptoDBTypes, false, strmangle.SetComplement(withdrawalCryptoPrimaryKeyColumns, withdrawalCryptoColumnsWithoutDefault)...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = randomize.Struct(seed, &b, withdrawalHistoryDBTypes, false, strmangle.SetComplement(withdrawalHistoryPrimaryKeyColumns, withdrawalHistoryColumnsWithoutDefault)...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = randomize.Struct(seed, &c, withdrawalHistoryDBTypes, false, strmangle.SetComplement(withdrawalHistoryPrimaryKeyColumns, withdrawalHistoryColumnsWithoutDefault)...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := a.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = b.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for i, x := range []*WithdrawalHistory{&b, &c} {
|
||||
err = a.SetWithdrawalCrypto(ctx, tx, i != 0, x)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if a.R.WithdrawalCrypto != x {
|
||||
t.Error("relationship struct not set to correct value")
|
||||
}
|
||||
|
||||
if x.R.WithdrawalCryptoWithdrawalCryptos[0] != &a {
|
||||
t.Error("failed to append to foreign relationship struct")
|
||||
}
|
||||
if !queries.Equal(a.WithdrawalCryptoID, x.ID) {
|
||||
t.Error("foreign key was wrong value", a.WithdrawalCryptoID)
|
||||
}
|
||||
|
||||
zero := reflect.Zero(reflect.TypeOf(a.WithdrawalCryptoID))
|
||||
reflect.Indirect(reflect.ValueOf(&a.WithdrawalCryptoID)).Set(zero)
|
||||
|
||||
if err = a.Reload(ctx, tx); err != nil {
|
||||
t.Fatal("failed to reload", err)
|
||||
}
|
||||
|
||||
if !queries.Equal(a.WithdrawalCryptoID, x.ID) {
|
||||
t.Error("foreign key was wrong value", a.WithdrawalCryptoID, x.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptoToOneRemoveOpWithdrawalHistoryUsingWithdrawalCrypto(t *testing.T) {
|
||||
var err error
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
var a WithdrawalCrypto
|
||||
var b WithdrawalHistory
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
if err = randomize.Struct(seed, &a, withdrawalCryptoDBTypes, false, strmangle.SetComplement(withdrawalCryptoPrimaryKeyColumns, withdrawalCryptoColumnsWithoutDefault)...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = randomize.Struct(seed, &b, withdrawalHistoryDBTypes, false, strmangle.SetComplement(withdrawalHistoryPrimaryKeyColumns, withdrawalHistoryColumnsWithoutDefault)...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err = a.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err = a.SetWithdrawalCrypto(ctx, tx, true, &b); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err = a.RemoveWithdrawalCrypto(ctx, tx, &b); err != nil {
|
||||
t.Error("failed to remove relationship")
|
||||
}
|
||||
|
||||
count, err := a.WithdrawalCrypto().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if count != 0 {
|
||||
t.Error("want no relationships remaining")
|
||||
}
|
||||
|
||||
if a.R.WithdrawalCrypto != nil {
|
||||
t.Error("R struct entry should be nil")
|
||||
}
|
||||
|
||||
if !queries.IsValuerNil(a.WithdrawalCryptoID) {
|
||||
t.Error("foreign key value should be nil")
|
||||
}
|
||||
|
||||
if len(b.R.WithdrawalCryptoWithdrawalCryptos) != 0 {
|
||||
t.Error("failed to remove a from b's relationships")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosReload(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if err = o.Reload(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosReloadAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
slice := WithdrawalCryptoSlice{o}
|
||||
|
||||
if err = slice.ReloadAll(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosSelect(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
slice, err := WithdrawalCryptos().All(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if len(slice) != 1 {
|
||||
t.Error("want one record, got:", len(slice))
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
withdrawalCryptoDBTypes = map[string]string{`ID`: `bigint`, `WithdrawalCryptoID`: `uuid`, `Address`: `text`, `AddressTag`: `text`, `Fee`: `double precision`}
|
||||
_ = bytes.MinRead
|
||||
)
|
||||
|
||||
func testWithdrawalCryptosUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if 0 == len(withdrawalCryptoPrimaryKeyColumns) {
|
||||
t.Skip("Skipping table with no primary key columns")
|
||||
}
|
||||
if len(withdrawalCryptoAllColumns) == len(withdrawalCryptoPrimaryKeyColumns) {
|
||||
t.Skip("Skipping table with only primary key columns")
|
||||
}
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalCryptos().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoPrimaryKeyColumns...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
if rowsAff, err := o.Update(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
} else if rowsAff != 1 {
|
||||
t.Error("should only affect one row but affected", rowsAff)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosSliceUpdateAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if len(withdrawalCryptoAllColumns) == len(withdrawalCryptoPrimaryKeyColumns) {
|
||||
t.Skip("Skipping table with only primary key columns")
|
||||
}
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalCryptos().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
|
||||
if err = randomize.Struct(seed, o, withdrawalCryptoDBTypes, true, withdrawalCryptoPrimaryKeyColumns...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
// Remove Primary keys and unique columns from what we plan to update
|
||||
var fields []string
|
||||
if strmangle.StringSliceMatch(withdrawalCryptoAllColumns, withdrawalCryptoPrimaryKeyColumns) {
|
||||
fields = withdrawalCryptoAllColumns
|
||||
} else {
|
||||
fields = strmangle.SetComplement(
|
||||
withdrawalCryptoAllColumns,
|
||||
withdrawalCryptoPrimaryKeyColumns,
|
||||
)
|
||||
}
|
||||
|
||||
value := reflect.Indirect(reflect.ValueOf(o))
|
||||
typ := reflect.TypeOf(o).Elem()
|
||||
n := typ.NumField()
|
||||
|
||||
updateMap := M{}
|
||||
for _, col := range fields {
|
||||
for i := 0; i < n; i++ {
|
||||
f := typ.Field(i)
|
||||
if f.Tag.Get("boil") == col {
|
||||
updateMap[col] = value.Field(i).Interface()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slice := WithdrawalCryptoSlice{o}
|
||||
if rowsAff, err := slice.UpdateAll(ctx, tx, updateMap); err != nil {
|
||||
t.Error(err)
|
||||
} else if rowsAff != 1 {
|
||||
t.Error("wanted one record updated but got", rowsAff)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalCryptosUpsert(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if len(withdrawalCryptoAllColumns) == len(withdrawalCryptoPrimaryKeyColumns) {
|
||||
t.Skip("Skipping table with only primary key columns")
|
||||
}
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
// Attempt the INSERT side of an UPSERT
|
||||
o := WithdrawalCrypto{}
|
||||
if err = randomize.Struct(seed, &o, withdrawalCryptoDBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Upsert(ctx, tx, false, nil, boil.Infer(), boil.Infer()); err != nil {
|
||||
t.Errorf("Unable to upsert WithdrawalCrypto: %s", err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalCryptos().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
|
||||
// Attempt the UPDATE side of an UPSERT
|
||||
if err = randomize.Struct(seed, &o, withdrawalCryptoDBTypes, false, withdrawalCryptoPrimaryKeyColumns...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalCrypto struct: %s", err)
|
||||
}
|
||||
|
||||
if err = o.Upsert(ctx, tx, true, nil, boil.Infer(), boil.Infer()); err != nil {
|
||||
t.Errorf("Unable to upsert WithdrawalCrypto: %s", err)
|
||||
}
|
||||
|
||||
count, err = WithdrawalCryptos().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
}
|
||||
1106
database/models/postgres/withdrawal_fiat.go
Normal file
1106
database/models/postgres/withdrawal_fiat.go
Normal file
File diff suppressed because it is too large
Load Diff
892
database/models/postgres/withdrawal_fiat_test.go
Normal file
892
database/models/postgres/withdrawal_fiat_test.go
Normal file
@@ -0,0 +1,892 @@
|
||||
// Code generated by SQLBoiler 3.5.0-gct (https://github.com/thrasher-corp/sqlboiler). DO NOT EDIT.
|
||||
// This file is meant to be re-generated in place and/or deleted at any time.
|
||||
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/thrasher-corp/sqlboiler/boil"
|
||||
"github.com/thrasher-corp/sqlboiler/queries"
|
||||
"github.com/thrasher-corp/sqlboiler/randomize"
|
||||
"github.com/thrasher-corp/sqlboiler/strmangle"
|
||||
)
|
||||
|
||||
var (
|
||||
// Relationships sometimes use the reflection helper queries.Equal/queries.Assign
|
||||
// so force a package dependency in case they don't.
|
||||
_ = queries.Equal
|
||||
)
|
||||
|
||||
func testWithdrawalFiats(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
query := WithdrawalFiats()
|
||||
|
||||
if query.Query == nil {
|
||||
t.Error("expected a query, got nothing")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsDelete(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rowsAff, err := o.Delete(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
} else if rowsAff != 1 {
|
||||
t.Error("should only have deleted one row, but affected:", rowsAff)
|
||||
}
|
||||
|
||||
count, err := WithdrawalFiats().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 0 {
|
||||
t.Error("want zero records, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsQueryDeleteAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if rowsAff, err := WithdrawalFiats().DeleteAll(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
} else if rowsAff != 1 {
|
||||
t.Error("should only have deleted one row, but affected:", rowsAff)
|
||||
}
|
||||
|
||||
count, err := WithdrawalFiats().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 0 {
|
||||
t.Error("want zero records, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsSliceDeleteAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
slice := WithdrawalFiatSlice{o}
|
||||
|
||||
if rowsAff, err := slice.DeleteAll(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
} else if rowsAff != 1 {
|
||||
t.Error("should only have deleted one row, but affected:", rowsAff)
|
||||
}
|
||||
|
||||
count, err := WithdrawalFiats().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 0 {
|
||||
t.Error("want zero records, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsExists(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
e, err := WithdrawalFiatExists(ctx, tx, o.ID)
|
||||
if err != nil {
|
||||
t.Errorf("Unable to check if WithdrawalFiat exists: %s", err)
|
||||
}
|
||||
if !e {
|
||||
t.Errorf("Expected WithdrawalFiatExists to return true, but got false.")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsFind(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
withdrawalFiatFound, err := FindWithdrawalFiat(ctx, tx, o.ID)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if withdrawalFiatFound == nil {
|
||||
t.Error("want a record, got nil")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsBind(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if err = WithdrawalFiats().Bind(ctx, tx, o); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsOne(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if x, err := WithdrawalFiats().One(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
} else if x == nil {
|
||||
t.Error("expected to get a non nil record")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
withdrawalFiatOne := &WithdrawalFiat{}
|
||||
withdrawalFiatTwo := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, withdrawalFiatOne, withdrawalFiatDBTypes, false, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
if err = randomize.Struct(seed, withdrawalFiatTwo, withdrawalFiatDBTypes, false, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = withdrawalFiatOne.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err = withdrawalFiatTwo.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
slice, err := WithdrawalFiats().All(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if len(slice) != 2 {
|
||||
t.Error("want 2 records, got:", len(slice))
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsCount(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var err error
|
||||
seed := randomize.NewSeed()
|
||||
withdrawalFiatOne := &WithdrawalFiat{}
|
||||
withdrawalFiatTwo := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, withdrawalFiatOne, withdrawalFiatDBTypes, false, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
if err = randomize.Struct(seed, withdrawalFiatTwo, withdrawalFiatDBTypes, false, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = withdrawalFiatOne.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if err = withdrawalFiatTwo.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalFiats().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 2 {
|
||||
t.Error("want 2 records, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func withdrawalFiatBeforeInsertHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalFiat) error {
|
||||
*o = WithdrawalFiat{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalFiatAfterInsertHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalFiat) error {
|
||||
*o = WithdrawalFiat{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalFiatAfterSelectHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalFiat) error {
|
||||
*o = WithdrawalFiat{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalFiatBeforeUpdateHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalFiat) error {
|
||||
*o = WithdrawalFiat{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalFiatAfterUpdateHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalFiat) error {
|
||||
*o = WithdrawalFiat{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalFiatBeforeDeleteHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalFiat) error {
|
||||
*o = WithdrawalFiat{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalFiatAfterDeleteHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalFiat) error {
|
||||
*o = WithdrawalFiat{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalFiatBeforeUpsertHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalFiat) error {
|
||||
*o = WithdrawalFiat{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func withdrawalFiatAfterUpsertHook(ctx context.Context, e boil.ContextExecutor, o *WithdrawalFiat) error {
|
||||
*o = WithdrawalFiat{}
|
||||
return nil
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsHooks(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var err error
|
||||
|
||||
ctx := context.Background()
|
||||
empty := &WithdrawalFiat{}
|
||||
o := &WithdrawalFiat{}
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, false); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat object: %s", err)
|
||||
}
|
||||
|
||||
AddWithdrawalFiatHook(boil.BeforeInsertHook, withdrawalFiatBeforeInsertHook)
|
||||
if err = o.doBeforeInsertHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doBeforeInsertHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected BeforeInsertHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalFiatBeforeInsertHooks = []WithdrawalFiatHook{}
|
||||
|
||||
AddWithdrawalFiatHook(boil.AfterInsertHook, withdrawalFiatAfterInsertHook)
|
||||
if err = o.doAfterInsertHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doAfterInsertHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected AfterInsertHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalFiatAfterInsertHooks = []WithdrawalFiatHook{}
|
||||
|
||||
AddWithdrawalFiatHook(boil.AfterSelectHook, withdrawalFiatAfterSelectHook)
|
||||
if err = o.doAfterSelectHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doAfterSelectHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected AfterSelectHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalFiatAfterSelectHooks = []WithdrawalFiatHook{}
|
||||
|
||||
AddWithdrawalFiatHook(boil.BeforeUpdateHook, withdrawalFiatBeforeUpdateHook)
|
||||
if err = o.doBeforeUpdateHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doBeforeUpdateHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected BeforeUpdateHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalFiatBeforeUpdateHooks = []WithdrawalFiatHook{}
|
||||
|
||||
AddWithdrawalFiatHook(boil.AfterUpdateHook, withdrawalFiatAfterUpdateHook)
|
||||
if err = o.doAfterUpdateHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doAfterUpdateHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected AfterUpdateHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalFiatAfterUpdateHooks = []WithdrawalFiatHook{}
|
||||
|
||||
AddWithdrawalFiatHook(boil.BeforeDeleteHook, withdrawalFiatBeforeDeleteHook)
|
||||
if err = o.doBeforeDeleteHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doBeforeDeleteHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected BeforeDeleteHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalFiatBeforeDeleteHooks = []WithdrawalFiatHook{}
|
||||
|
||||
AddWithdrawalFiatHook(boil.AfterDeleteHook, withdrawalFiatAfterDeleteHook)
|
||||
if err = o.doAfterDeleteHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doAfterDeleteHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected AfterDeleteHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalFiatAfterDeleteHooks = []WithdrawalFiatHook{}
|
||||
|
||||
AddWithdrawalFiatHook(boil.BeforeUpsertHook, withdrawalFiatBeforeUpsertHook)
|
||||
if err = o.doBeforeUpsertHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doBeforeUpsertHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected BeforeUpsertHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalFiatBeforeUpsertHooks = []WithdrawalFiatHook{}
|
||||
|
||||
AddWithdrawalFiatHook(boil.AfterUpsertHook, withdrawalFiatAfterUpsertHook)
|
||||
if err = o.doAfterUpsertHooks(ctx, nil); err != nil {
|
||||
t.Errorf("Unable to execute doAfterUpsertHooks: %s", err)
|
||||
}
|
||||
if !reflect.DeepEqual(o, empty) {
|
||||
t.Errorf("Expected AfterUpsertHook function to empty object, but got: %#v", o)
|
||||
}
|
||||
withdrawalFiatAfterUpsertHooks = []WithdrawalFiatHook{}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsInsert(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalFiats().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsInsertWhitelist(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Whitelist(withdrawalFiatColumnsWithoutDefault...)); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalFiats().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatToOneWithdrawalHistoryUsingWithdrawalFiat(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
var local WithdrawalFiat
|
||||
var foreign WithdrawalHistory
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
if err := randomize.Struct(seed, &local, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
if err := randomize.Struct(seed, &foreign, withdrawalHistoryDBTypes, false, withdrawalHistoryColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalHistory struct: %s", err)
|
||||
}
|
||||
|
||||
if err := foreign.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
queries.Assign(&local.WithdrawalFiatID, foreign.ID)
|
||||
if err := local.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
check, err := local.WithdrawalFiat().One(ctx, tx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !queries.Equal(check.ID, foreign.ID) {
|
||||
t.Errorf("want: %v, got %v", foreign.ID, check.ID)
|
||||
}
|
||||
|
||||
slice := WithdrawalFiatSlice{&local}
|
||||
if err = local.L.LoadWithdrawalFiat(ctx, tx, false, (*[]*WithdrawalFiat)(&slice), nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if local.R.WithdrawalFiat == nil {
|
||||
t.Error("struct should have been eager loaded")
|
||||
}
|
||||
|
||||
local.R.WithdrawalFiat = nil
|
||||
if err = local.L.LoadWithdrawalFiat(ctx, tx, true, &local, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if local.R.WithdrawalFiat == nil {
|
||||
t.Error("struct should have been eager loaded")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatToOneSetOpWithdrawalHistoryUsingWithdrawalFiat(t *testing.T) {
|
||||
var err error
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
var a WithdrawalFiat
|
||||
var b, c WithdrawalHistory
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
if err = randomize.Struct(seed, &a, withdrawalFiatDBTypes, false, strmangle.SetComplement(withdrawalFiatPrimaryKeyColumns, withdrawalFiatColumnsWithoutDefault)...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = randomize.Struct(seed, &b, withdrawalHistoryDBTypes, false, strmangle.SetComplement(withdrawalHistoryPrimaryKeyColumns, withdrawalHistoryColumnsWithoutDefault)...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = randomize.Struct(seed, &c, withdrawalHistoryDBTypes, false, strmangle.SetComplement(withdrawalHistoryPrimaryKeyColumns, withdrawalHistoryColumnsWithoutDefault)...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := a.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = b.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for i, x := range []*WithdrawalHistory{&b, &c} {
|
||||
err = a.SetWithdrawalFiat(ctx, tx, i != 0, x)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if a.R.WithdrawalFiat != x {
|
||||
t.Error("relationship struct not set to correct value")
|
||||
}
|
||||
|
||||
if x.R.WithdrawalFiatWithdrawalFiats[0] != &a {
|
||||
t.Error("failed to append to foreign relationship struct")
|
||||
}
|
||||
if !queries.Equal(a.WithdrawalFiatID, x.ID) {
|
||||
t.Error("foreign key was wrong value", a.WithdrawalFiatID)
|
||||
}
|
||||
|
||||
zero := reflect.Zero(reflect.TypeOf(a.WithdrawalFiatID))
|
||||
reflect.Indirect(reflect.ValueOf(&a.WithdrawalFiatID)).Set(zero)
|
||||
|
||||
if err = a.Reload(ctx, tx); err != nil {
|
||||
t.Fatal("failed to reload", err)
|
||||
}
|
||||
|
||||
if !queries.Equal(a.WithdrawalFiatID, x.ID) {
|
||||
t.Error("foreign key was wrong value", a.WithdrawalFiatID, x.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatToOneRemoveOpWithdrawalHistoryUsingWithdrawalFiat(t *testing.T) {
|
||||
var err error
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
|
||||
var a WithdrawalFiat
|
||||
var b WithdrawalHistory
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
if err = randomize.Struct(seed, &a, withdrawalFiatDBTypes, false, strmangle.SetComplement(withdrawalFiatPrimaryKeyColumns, withdrawalFiatColumnsWithoutDefault)...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = randomize.Struct(seed, &b, withdrawalHistoryDBTypes, false, strmangle.SetComplement(withdrawalHistoryPrimaryKeyColumns, withdrawalHistoryColumnsWithoutDefault)...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err = a.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err = a.SetWithdrawalFiat(ctx, tx, true, &b); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err = a.RemoveWithdrawalFiat(ctx, tx, &b); err != nil {
|
||||
t.Error("failed to remove relationship")
|
||||
}
|
||||
|
||||
count, err := a.WithdrawalFiat().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if count != 0 {
|
||||
t.Error("want no relationships remaining")
|
||||
}
|
||||
|
||||
if a.R.WithdrawalFiat != nil {
|
||||
t.Error("R struct entry should be nil")
|
||||
}
|
||||
|
||||
if !queries.IsValuerNil(a.WithdrawalFiatID) {
|
||||
t.Error("foreign key value should be nil")
|
||||
}
|
||||
|
||||
if len(b.R.WithdrawalFiatWithdrawalFiats) != 0 {
|
||||
t.Error("failed to remove a from b's relationships")
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsReload(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if err = o.Reload(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsReloadAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
slice := WithdrawalFiatSlice{o}
|
||||
|
||||
if err = slice.ReloadAll(ctx, tx); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsSelect(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
slice, err := WithdrawalFiats().All(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if len(slice) != 1 {
|
||||
t.Error("want one record, got:", len(slice))
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
withdrawalFiatDBTypes = map[string]string{`ID`: `bigint`, `WithdrawalFiatID`: `uuid`, `BankName`: `text`, `BankAddress`: `text`, `BankAccountName`: `text`, `BankAccountNumber`: `text`, `BSB`: `text`, `SwiftCode`: `text`, `Iban`: `text`, `BankCode`: `double precision`}
|
||||
_ = bytes.MinRead
|
||||
)
|
||||
|
||||
func testWithdrawalFiatsUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if 0 == len(withdrawalFiatPrimaryKeyColumns) {
|
||||
t.Skip("Skipping table with no primary key columns")
|
||||
}
|
||||
if len(withdrawalFiatAllColumns) == len(withdrawalFiatPrimaryKeyColumns) {
|
||||
t.Skip("Skipping table with only primary key columns")
|
||||
}
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalFiats().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatPrimaryKeyColumns...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
if rowsAff, err := o.Update(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
} else if rowsAff != 1 {
|
||||
t.Error("should only affect one row but affected", rowsAff)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsSliceUpdateAll(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if len(withdrawalFiatAllColumns) == len(withdrawalFiatPrimaryKeyColumns) {
|
||||
t.Skip("Skipping table with only primary key columns")
|
||||
}
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
o := &WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatColumnsWithDefault...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Insert(ctx, tx, boil.Infer()); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalFiats().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
|
||||
if err = randomize.Struct(seed, o, withdrawalFiatDBTypes, true, withdrawalFiatPrimaryKeyColumns...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
// Remove Primary keys and unique columns from what we plan to update
|
||||
var fields []string
|
||||
if strmangle.StringSliceMatch(withdrawalFiatAllColumns, withdrawalFiatPrimaryKeyColumns) {
|
||||
fields = withdrawalFiatAllColumns
|
||||
} else {
|
||||
fields = strmangle.SetComplement(
|
||||
withdrawalFiatAllColumns,
|
||||
withdrawalFiatPrimaryKeyColumns,
|
||||
)
|
||||
}
|
||||
|
||||
value := reflect.Indirect(reflect.ValueOf(o))
|
||||
typ := reflect.TypeOf(o).Elem()
|
||||
n := typ.NumField()
|
||||
|
||||
updateMap := M{}
|
||||
for _, col := range fields {
|
||||
for i := 0; i < n; i++ {
|
||||
f := typ.Field(i)
|
||||
if f.Tag.Get("boil") == col {
|
||||
updateMap[col] = value.Field(i).Interface()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slice := WithdrawalFiatSlice{o}
|
||||
if rowsAff, err := slice.UpdateAll(ctx, tx, updateMap); err != nil {
|
||||
t.Error(err)
|
||||
} else if rowsAff != 1 {
|
||||
t.Error("wanted one record updated but got", rowsAff)
|
||||
}
|
||||
}
|
||||
|
||||
func testWithdrawalFiatsUpsert(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if len(withdrawalFiatAllColumns) == len(withdrawalFiatPrimaryKeyColumns) {
|
||||
t.Skip("Skipping table with only primary key columns")
|
||||
}
|
||||
|
||||
seed := randomize.NewSeed()
|
||||
var err error
|
||||
// Attempt the INSERT side of an UPSERT
|
||||
o := WithdrawalFiat{}
|
||||
if err = randomize.Struct(seed, &o, withdrawalFiatDBTypes, true); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
tx := MustTx(boil.BeginTx(ctx, nil))
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if err = o.Upsert(ctx, tx, false, nil, boil.Infer(), boil.Infer()); err != nil {
|
||||
t.Errorf("Unable to upsert WithdrawalFiat: %s", err)
|
||||
}
|
||||
|
||||
count, err := WithdrawalFiats().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
|
||||
// Attempt the UPDATE side of an UPSERT
|
||||
if err = randomize.Struct(seed, &o, withdrawalFiatDBTypes, false, withdrawalFiatPrimaryKeyColumns...); err != nil {
|
||||
t.Errorf("Unable to randomize WithdrawalFiat struct: %s", err)
|
||||
}
|
||||
|
||||
if err = o.Upsert(ctx, tx, true, nil, boil.Infer(), boil.Infer()); err != nil {
|
||||
t.Errorf("Unable to upsert WithdrawalFiat: %s", err)
|
||||
}
|
||||
|
||||
count, err = WithdrawalFiats().Count(ctx, tx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if count != 1 {
|
||||
t.Error("want one record, got:", count)
|
||||
}
|
||||
}
|
||||
1406
database/models/postgres/withdrawal_history.go
Normal file
1406
database/models/postgres/withdrawal_history.go
Normal file
File diff suppressed because it is too large
Load Diff
1388
database/models/postgres/withdrawal_history_test.go
Normal file
1388
database/models/postgres/withdrawal_history_test.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user