(Feat): Initial Commit
Some checks failed
Build & Test / build-test (push) Has been cancelled
Build & Test / swagger-codegen-cli (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled

This commit is contained in:
2026-07-03 19:41:31 +05:30
commit 7e940c83a7
461 changed files with 45002 additions and 0 deletions

View File

@@ -0,0 +1,701 @@
// Code generated by SQLBoiler 4.19.5 (https://github.com/aarondl/sqlboiler). DO NOT EDIT.
// This file is meant to be re-generated in place and/or deleted at any time.
package models
import (
"bytes"
"context"
"reflect"
"testing"
"github.com/aarondl/randomize"
"github.com/aarondl/sqlboiler/v4/boil"
"github.com/aarondl/sqlboiler/v4/queries"
"github.com/aarondl/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 testConfirmationTokens(t *testing.T) {
t.Parallel()
query := ConfirmationTokens()
if query.Query == nil {
t.Error("expected a query, got nothing")
}
}
func testConfirmationTokensDelete(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 := ConfirmationTokens().Count(ctx, tx)
if err != nil {
t.Error(err)
}
if count != 0 {
t.Error("want zero records, got:", count)
}
}
func testConfirmationTokensQueryDeleteAll(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 := ConfirmationTokens().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 := ConfirmationTokens().Count(ctx, tx)
if err != nil {
t.Error(err)
}
if count != 0 {
t.Error("want zero records, got:", count)
}
}
func testConfirmationTokensSliceDeleteAll(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 := ConfirmationTokenSlice{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 := ConfirmationTokens().Count(ctx, tx)
if err != nil {
t.Error(err)
}
if count != 0 {
t.Error("want zero records, got:", count)
}
}
func testConfirmationTokensExists(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 := ConfirmationTokenExists(ctx, tx, o.Token)
if err != nil {
t.Errorf("Unable to check if ConfirmationToken exists: %s", err)
}
if !e {
t.Errorf("Expected ConfirmationTokenExists to return true, but got false.")
}
}
func testConfirmationTokensFind(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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)
}
confirmationTokenFound, err := FindConfirmationToken(ctx, tx, o.Token)
if err != nil {
t.Error(err)
}
if confirmationTokenFound == nil {
t.Error("want a record, got nil")
}
}
func testConfirmationTokensBind(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 = ConfirmationTokens().Bind(ctx, tx, o); err != nil {
t.Error(err)
}
}
func testConfirmationTokensOne(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 := ConfirmationTokens().One(ctx, tx); err != nil {
t.Error(err)
} else if x == nil {
t.Error("expected to get a non nil record")
}
}
func testConfirmationTokensAll(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
confirmationTokenOne := &ConfirmationToken{}
confirmationTokenTwo := &ConfirmationToken{}
if err = randomize.Struct(seed, confirmationTokenOne, confirmationTokenDBTypes, false, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken struct: %s", err)
}
if err = randomize.Struct(seed, confirmationTokenTwo, confirmationTokenDBTypes, false, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken struct: %s", err)
}
ctx := context.Background()
tx := MustTx(boil.BeginTx(ctx, nil))
defer func() { _ = tx.Rollback() }()
if err = confirmationTokenOne.Insert(ctx, tx, boil.Infer()); err != nil {
t.Error(err)
}
if err = confirmationTokenTwo.Insert(ctx, tx, boil.Infer()); err != nil {
t.Error(err)
}
slice, err := ConfirmationTokens().All(ctx, tx)
if err != nil {
t.Error(err)
}
if len(slice) != 2 {
t.Error("want 2 records, got:", len(slice))
}
}
func testConfirmationTokensCount(t *testing.T) {
t.Parallel()
var err error
seed := randomize.NewSeed()
confirmationTokenOne := &ConfirmationToken{}
confirmationTokenTwo := &ConfirmationToken{}
if err = randomize.Struct(seed, confirmationTokenOne, confirmationTokenDBTypes, false, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken struct: %s", err)
}
if err = randomize.Struct(seed, confirmationTokenTwo, confirmationTokenDBTypes, false, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken struct: %s", err)
}
ctx := context.Background()
tx := MustTx(boil.BeginTx(ctx, nil))
defer func() { _ = tx.Rollback() }()
if err = confirmationTokenOne.Insert(ctx, tx, boil.Infer()); err != nil {
t.Error(err)
}
if err = confirmationTokenTwo.Insert(ctx, tx, boil.Infer()); err != nil {
t.Error(err)
}
count, err := ConfirmationTokens().Count(ctx, tx)
if err != nil {
t.Error(err)
}
if count != 2 {
t.Error("want 2 records, got:", count)
}
}
func testConfirmationTokensInsert(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 := ConfirmationTokens().Count(ctx, tx)
if err != nil {
t.Error(err)
}
if count != 1 {
t.Error("want one record, got:", count)
}
}
func testConfirmationTokensInsertWhitelist(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true); err != nil {
t.Errorf("Unable to randomize ConfirmationToken struct: %s", err)
}
ctx := context.Background()
tx := MustTx(boil.BeginTx(ctx, nil))
defer func() { _ = tx.Rollback() }()
if err = o.Insert(ctx, tx, boil.Whitelist(strmangle.SetMerge(confirmationTokenPrimaryKeyColumns, confirmationTokenColumnsWithoutDefault)...)); err != nil {
t.Error(err)
}
count, err := ConfirmationTokens().Count(ctx, tx)
if err != nil {
t.Error(err)
}
if count != 1 {
t.Error("want one record, got:", count)
}
}
func testConfirmationTokenToOneUserUsingUser(t *testing.T) {
ctx := context.Background()
tx := MustTx(boil.BeginTx(ctx, nil))
defer func() { _ = tx.Rollback() }()
var local ConfirmationToken
var foreign User
seed := randomize.NewSeed()
if err := randomize.Struct(seed, &local, confirmationTokenDBTypes, false, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken struct: %s", err)
}
if err := randomize.Struct(seed, &foreign, userDBTypes, false, userColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize User struct: %s", err)
}
if err := foreign.Insert(ctx, tx, boil.Infer()); err != nil {
t.Fatal(err)
}
local.UserID = foreign.ID
if err := local.Insert(ctx, tx, boil.Infer()); err != nil {
t.Fatal(err)
}
check, err := local.User().One(ctx, tx)
if err != nil {
t.Fatal(err)
}
if check.ID != foreign.ID {
t.Errorf("want: %v, got %v", foreign.ID, check.ID)
}
slice := ConfirmationTokenSlice{&local}
if err = local.L.LoadUser(ctx, tx, false, (*[]*ConfirmationToken)(&slice), nil); err != nil {
t.Fatal(err)
}
if local.R.User == nil {
t.Error("struct should have been eager loaded")
}
local.R.User = nil
if err = local.L.LoadUser(ctx, tx, true, &local, nil); err != nil {
t.Fatal(err)
}
if local.R.User == nil {
t.Error("struct should have been eager loaded")
}
}
func testConfirmationTokenToOneSetOpUserUsingUser(t *testing.T) {
var err error
ctx := context.Background()
tx := MustTx(boil.BeginTx(ctx, nil))
defer func() { _ = tx.Rollback() }()
var a ConfirmationToken
var b, c User
seed := randomize.NewSeed()
if err = randomize.Struct(seed, &a, confirmationTokenDBTypes, false, strmangle.SetComplement(confirmationTokenPrimaryKeyColumns, confirmationTokenColumnsWithoutDefault)...); err != nil {
t.Fatal(err)
}
if err = randomize.Struct(seed, &b, userDBTypes, false, strmangle.SetComplement(userPrimaryKeyColumns, userColumnsWithoutDefault)...); err != nil {
t.Fatal(err)
}
if err = randomize.Struct(seed, &c, userDBTypes, false, strmangle.SetComplement(userPrimaryKeyColumns, userColumnsWithoutDefault)...); 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 []*User{&b, &c} {
err = a.SetUser(ctx, tx, i != 0, x)
if err != nil {
t.Fatal(err)
}
if a.R.User != x {
t.Error("relationship struct not set to correct value")
}
if x.R.ConfirmationTokens[0] != &a {
t.Error("failed to append to foreign relationship struct")
}
if a.UserID != x.ID {
t.Error("foreign key was wrong value", a.UserID)
}
zero := reflect.Zero(reflect.TypeOf(a.UserID))
reflect.Indirect(reflect.ValueOf(&a.UserID)).Set(zero)
if err = a.Reload(ctx, tx); err != nil {
t.Fatal("failed to reload", err)
}
if a.UserID != x.ID {
t.Error("foreign key was wrong value", a.UserID, x.ID)
}
}
}
func testConfirmationTokensReload(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 testConfirmationTokensReloadAll(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 := ConfirmationTokenSlice{o}
if err = slice.ReloadAll(ctx, tx); err != nil {
t.Error(err)
}
}
func testConfirmationTokensSelect(t *testing.T) {
t.Parallel()
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 := ConfirmationTokens().All(ctx, tx)
if err != nil {
t.Error(err)
}
if len(slice) != 1 {
t.Error("want one record, got:", len(slice))
}
}
var (
confirmationTokenDBTypes = map[string]string{`Token`: `uuid`, `ValidUntil`: `timestamp with time zone`, `UserID`: `uuid`, `CreatedAt`: `timestamp with time zone`, `UpdatedAt`: `timestamp with time zone`}
_ = bytes.MinRead
)
func testConfirmationTokensUpdate(t *testing.T) {
t.Parallel()
if 0 == len(confirmationTokenPrimaryKeyColumns) {
t.Skip("Skipping table with no primary key columns")
}
if len(confirmationTokenAllColumns) == len(confirmationTokenPrimaryKeyColumns) {
t.Skip("Skipping table with only primary key columns")
}
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 := ConfirmationTokens().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, confirmationTokenDBTypes, true, confirmationTokenPrimaryKeyColumns...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 testConfirmationTokensSliceUpdateAll(t *testing.T) {
t.Parallel()
if len(confirmationTokenAllColumns) == len(confirmationTokenPrimaryKeyColumns) {
t.Skip("Skipping table with only primary key columns")
}
seed := randomize.NewSeed()
var err error
o := &ConfirmationToken{}
if err = randomize.Struct(seed, o, confirmationTokenDBTypes, true, confirmationTokenColumnsWithDefault...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 := ConfirmationTokens().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, confirmationTokenDBTypes, true, confirmationTokenPrimaryKeyColumns...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken struct: %s", err)
}
// Remove Primary keys and unique columns from what we plan to update
var fields []string
if strmangle.StringSliceMatch(confirmationTokenAllColumns, confirmationTokenPrimaryKeyColumns) {
fields = confirmationTokenAllColumns
} else {
fields = strmangle.SetComplement(
confirmationTokenAllColumns,
confirmationTokenPrimaryKeyColumns,
)
}
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 := ConfirmationTokenSlice{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 testConfirmationTokensUpsert(t *testing.T) {
t.Parallel()
if len(confirmationTokenAllColumns) == len(confirmationTokenPrimaryKeyColumns) {
t.Skip("Skipping table with only primary key columns")
}
seed := randomize.NewSeed()
var err error
// Attempt the INSERT side of an UPSERT
o := ConfirmationToken{}
if err = randomize.Struct(seed, &o, confirmationTokenDBTypes, true); err != nil {
t.Errorf("Unable to randomize ConfirmationToken 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 ConfirmationToken: %s", err)
}
count, err := ConfirmationTokens().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, confirmationTokenDBTypes, false, confirmationTokenPrimaryKeyColumns...); err != nil {
t.Errorf("Unable to randomize ConfirmationToken struct: %s", err)
}
if err = o.Upsert(ctx, tx, true, nil, boil.Infer(), boil.Infer()); err != nil {
t.Errorf("Unable to upsert ConfirmationToken: %s", err)
}
count, err = ConfirmationTokens().Count(ctx, tx)
if err != nil {
t.Error(err)
}
if count != 1 {
t.Error("want one record, got:", count)
}
}