change db.createAccounTx output from CreateAccountTxResult to Account (#33)
This commit is contained in:
parent
1ad3aa8d4f
commit
b5f39995b2
@ -58,29 +58,14 @@ func TestCreateAccountAPI(t *testing.T) {
|
||||
Creator: account.Creator,
|
||||
}
|
||||
|
||||
exp := db.CreateAccountTxResult{
|
||||
Account: account,
|
||||
}
|
||||
|
||||
store.EXPECT().
|
||||
CreateAccountTx(gomock.Any(), gomock.Eq(arg)).
|
||||
Times(1).
|
||||
Return(exp, nil)
|
||||
Return(account, nil)
|
||||
},
|
||||
checkResponse: func(recorder *httptest.ResponseRecorder) {
|
||||
require.Equal(t, http.StatusOK, recorder.Code)
|
||||
data, err := io.ReadAll(recorder.Body)
|
||||
require.NoError(t, err)
|
||||
|
||||
var getAccount db.CreateAccountTxResult
|
||||
err = json.Unmarshal(data, &getAccount)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
db.CreateAccountTxResult{
|
||||
Account: account,
|
||||
},
|
||||
getAccount,
|
||||
)
|
||||
requireBodyMatchAccount(t, recorder.Body, account)
|
||||
},
|
||||
},
|
||||
// {
|
||||
@ -130,7 +115,7 @@ func TestCreateAccountAPI(t *testing.T) {
|
||||
store.EXPECT().
|
||||
CreateAccountTx(gomock.Any(), gomock.Any()).
|
||||
Times(1).
|
||||
Return(db.CreateAccountTxResult{}, sql.ErrConnDone)
|
||||
Return(db.Account{}, sql.ErrConnDone)
|
||||
},
|
||||
checkResponse: func(recorder *httptest.ResponseRecorder) {
|
||||
require.Equal(t, http.StatusInternalServerError, recorder.Code)
|
||||
|
@ -55,10 +55,10 @@ func (mr *MockStoreMockRecorder) CreateAccount(arg0, arg1 any) *gomock.Call {
|
||||
}
|
||||
|
||||
// CreateAccountTx mocks base method.
|
||||
func (m *MockStore) CreateAccountTx(arg0 context.Context, arg1 db.CreateAccountTxParams) (db.CreateAccountTxResult, error) {
|
||||
func (m *MockStore) CreateAccountTx(arg0 context.Context, arg1 db.CreateAccountTxParams) (db.Account, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "CreateAccountTx", arg0, arg1)
|
||||
ret0, _ := ret[0].(db.CreateAccountTxResult)
|
||||
ret0, _ := ret[0].(db.Account)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
|
||||
type Store interface {
|
||||
Querier
|
||||
CreateAccountTx(ctx context.Context, arg CreateAccountTxParams) (CreateAccountTxResult, error)
|
||||
CreateAccountTx(ctx context.Context, arg CreateAccountTxParams) (Account, error)
|
||||
UpdateAccountTx(ctx context.Context, arg UpdateAccountTxParams) (Account, error)
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ type CreateAccountTxResult struct {
|
||||
Account Account `json:"account"`
|
||||
}
|
||||
|
||||
func (store *SQLStore) CreateAccountTx(ctx context.Context, arg CreateAccountTxParams) (CreateAccountTxResult, error) {
|
||||
func (store *SQLStore) CreateAccountTx(ctx context.Context, arg CreateAccountTxParams) (Account, error) {
|
||||
var result CreateAccountTxResult
|
||||
|
||||
err := store.execTx(ctx, func(q *Queries) error {
|
||||
@ -47,5 +47,5 @@ func (store *SQLStore) CreateAccountTx(ctx context.Context, arg CreateAccountTxP
|
||||
return err
|
||||
})
|
||||
|
||||
return result, err
|
||||
return result.Account, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user