7 acc "github.com/vapor/account"
8 dbm "github.com/vapor/database/leveldb"
11 func TestDeleteAccount(t *testing.T) {
12 testDB := dbm.NewDB("testdb", "leveldb", "temp")
19 accounts []*acc.Account
20 deleteAccount *acc.Account
24 accounts: []*acc.Account{},
25 deleteAccount: &acc.Account{},
26 want: []*acc.Account{},
29 accounts: []*acc.Account{},
30 deleteAccount: &acc.Account{
34 want: []*acc.Account{},
37 accounts: []*acc.Account{
47 deleteAccount: &acc.Account{},
60 accounts: []*acc.Account{
70 deleteAccount: &acc.Account{
86 accounts: []*acc.Account{
96 deleteAccount: &acc.Account{
100 want: []*acc.Account{
109 accountStore := NewAccountStore(testDB)
110 for i, c := range cases {
111 // store mock accounts
112 for _, a := range c.accounts {
113 if err := accountStore.SetAccount(a); err != nil {
119 if err := accountStore.DeleteAccount(c.deleteAccount); err != nil {
123 // get account by deleteAccount.ID, it should print ErrFindAccount
124 if _, err := accountStore.GetAccountByID(c.deleteAccount.ID); err != acc.ErrFindAccount {
128 for _, a := range c.want {
129 if _, err := accountStore.GetAccountByID(a.ID); err == acc.ErrFindAccount {
130 t.Errorf("case %v: cann't find account, err: %v", i, err)