Bootstrap copied BFF and local accounts with public Sendico contracts (#34)
This commit is contained in:
1 parent
67dc5b5b1e
commit
7062672a87
556 files changed
+42291
-777
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestAccountCopyDeepCopiesMetadata(t *testing.T) {
|
||||
account := &Account{
|
||||
AccountPublic: AccountPublic{
|
||||
AccountBase: AccountBase{
|
||||
Metadata: &AccountMetadata{
|
||||
PersonalLedgerProvisioning: &LedgerProvisioningMetadata{
|
||||
Source: "invitation",
|
||||
InvitationRef: "invitation-ref",
|
||||
TargetCurrencies: []string{"RUB", "USDT"},
|
||||
Created: []string{"RUB"},
|
||||
AlreadyExisting: []string{"USDT"},
|
||||
Failed: []LedgerProvisioningFailure{{Currency: "EUR", ErrorClass: "timeout"}},
|
||||
Outcome: "partial_failure",
|
||||
LastErrorClass: "timeout",
|
||||
LastAttemptAt: time.Now().UTC(),
|
||||
},
|
||||
},
|
||||
},
|
||||
UserDataBase: UserDataBase{Login: "invitee@example.com"},
|
||||
},
|
||||
Password: "secret",
|
||||
Status: AccountActive,
|
||||
}
|
||||
|
||||
copied := account.Copy()
|
||||
copied.Metadata.PersonalLedgerProvisioning.TargetCurrencies[0] = "EUR"
|
||||
copied.Metadata.PersonalLedgerProvisioning.Created[0] = "EUR"
|
||||
copied.Metadata.PersonalLedgerProvisioning.AlreadyExisting[0] = "EUR"
|
||||
copied.Metadata.PersonalLedgerProvisioning.Failed[0].ErrorClass = "ledger_unavailable"
|
||||
|
||||
metadata := account.Metadata.PersonalLedgerProvisioning
|
||||
if metadata.TargetCurrencies[0] != "RUB" {
|
||||
t.Fatalf("expected original target currency to remain RUB, got %q", metadata.TargetCurrencies[0])
|
||||
}
|
||||
if metadata.Created[0] != "RUB" {
|
||||
t.Fatalf("expected original created currency to remain RUB, got %q", metadata.Created[0])
|
||||
}
|
||||
if metadata.AlreadyExisting[0] != "USDT" {
|
||||
t.Fatalf("expected original existing currency to remain USDT, got %q", metadata.AlreadyExisting[0])
|
||||
}
|
||||
if metadata.Failed[0].ErrorClass != "timeout" {
|
||||
t.Fatalf("expected original failure class to remain timeout, got %q", metadata.Failed[0].ErrorClass)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user