Correct result structs for mock/test api implementations

This commit is contained in:
lash 2025-01-14 14:20:51 +00:00
parent 7a96b85b28
commit 9645a2af7b
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
4 changed files with 21 additions and 7 deletions

View File

@ -3,6 +3,7 @@ package http
import (
"bytes"
"context"
"fmt"
"encoding/json"
"errors"
"io"
@ -202,8 +203,8 @@ func (as *HTTPAccountService) TokenTransfer(ctx context.Context, amount, from, t
// CheckAliasAddress retrieves the address of an alias from the API endpoint.
// Parameters:
// - alias: The alias of the user.
func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias string) (*dataserviceapi.AliasAddress, error) {
var r dataserviceapi.AliasAddress
func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
var r models.AliasAddress
ep, err := url.JoinPath(config.CheckAliasURL, alias)
if err != nil {
@ -219,6 +220,10 @@ func (as *HTTPAccountService) CheckAliasAddress(ctx context.Context, alias strin
return &r, err
}
func (as *HTTPAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
return nil, fmt.Errorf("not yet implemented")
}
// TODO: remove eth-custodial api dependency
func doRequest(ctx context.Context, req *http.Request, rcpt any) (*api.OKResponse, error) {
var okResponse api.OKResponse

View File

@ -50,7 +50,7 @@ func(m MockApi) VoucherData(ctx context.Context, address string) (*models.Vouche
return m.VoucherDataContent, nil
}
func(m MockApi) CheckAliasAddress(ctx context.Context, alias string) (*dataserviceapi.AliasAddress, error) {
func(m MockApi) CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
return nil, nil
}

View File

@ -48,7 +48,12 @@ func (m *MockAccountService) TokenTransfer(ctx context.Context, amount, from, to
return args.Get(0).(*models.TokenTransferResponse), args.Error(1)
}
func (m *MockAccountService) CheckAliasAddress(ctx context.Context, alias string) (*dataserviceapi.AliasAddress, error) {
func (m *MockAccountService) CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
args := m.Called(alias)
return args.Get(0).(*dataserviceapi.AliasAddress), args.Error(1)
return args.Get(0).(*models.AliasAddress), args.Error(1)
}
func(m MockAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
args := m.Called(publicKey, hint)
return args.Get(0).(*models.RequestAliasResult), args.Error(1)
}

View File

@ -57,6 +57,10 @@ func (tas *TestAccountService) TokenTransfer(ctx context.Context, amount, from,
}, nil
}
func (m TestAccountService) CheckAliasAddress(ctx context.Context, alias string) (*dataserviceapi.AliasAddress, error) {
return &dataserviceapi.AliasAddress{}, nil
func (m TestAccountService) CheckAliasAddress(ctx context.Context, alias string) (*models.AliasAddress, error) {
return &models.AliasAddress{}, nil
}
func (m TestAccountService) RequestAlias(ctx context.Context, publicKey string, hint string) (*models.RequestAliasResult, error) {
return &models.RequestAliasResult{}, nil
}