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