github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/test/patch_models/access_key.go (about)

     1  package patch_models
     2  
     3  import (
     4  	"reflect"
     5  
     6  	"github.com/agiledragon/gomonkey/v2"
     7  
     8  	"github.com/machinefi/w3bstream/pkg/depends/kit/sqlx"
     9  	"github.com/machinefi/w3bstream/pkg/depends/kit/sqlx/builder"
    10  	"github.com/machinefi/w3bstream/pkg/models"
    11  )
    12  
    13  var _tarModelAccessKey = reflect.TypeOf(&models.AccessKey{})
    14  
    15  func AccessKeyFetchByRand(patch *gomonkey.Patches, overwrite *models.AccessKey, err error) *gomonkey.Patches {
    16  	return patch.ApplyMethod(
    17  		_tarModelAccessKey,
    18  		"FetchByRand",
    19  		func(receiver *models.AccessKey, d sqlx.DBExecutor) error {
    20  			if overwrite != nil {
    21  				*receiver = *overwrite
    22  			}
    23  			return nil
    24  		},
    25  	)
    26  }
    27  
    28  func AccessKeyList(patch *gomonkey.Patches, v []models.AccessKey, err error) *gomonkey.Patches {
    29  	return patch.ApplyMethod(
    30  		_tarModelAccessKey,
    31  		"List",
    32  		func(_ *models.AccessKey, _ sqlx.DBExecutor, _ builder.SqlCondition, _ ...builder.Addition) ([]models.AccessKey, error) {
    33  			return v, err
    34  		},
    35  	)
    36  }
    37  
    38  func AccessKeyCount(patch *gomonkey.Patches, n int64, err error) *gomonkey.Patches {
    39  	return patch.ApplyMethod(
    40  		_tarModelAccessKey,
    41  		"Count",
    42  		func(_ *models.AccessKey, _ sqlx.DBExecutor, _ builder.SqlCondition, _ ...builder.Addition) (int64, error) {
    43  			return n, err
    44  		},
    45  	)
    46  }
    47  
    48  func AccessKeyFetchByAccountIDAndName(patch *gomonkey.Patches, overwrite *models.AccessKey, err error) *gomonkey.Patches {
    49  	return patch.ApplyMethod(
    50  		_tarModelAccessKey,
    51  		"FetchByAccountIDAndName",
    52  		func(receiver *models.AccessKey, _ sqlx.DBExecutor) error {
    53  			if overwrite != nil {
    54  				*receiver = *overwrite
    55  			}
    56  			return err
    57  		},
    58  	)
    59  }