Skip to content

Commit

Permalink
fixed unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ortuman committed May 20, 2018
1 parent 55f2b62 commit 76fa47d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions module/xep0191/block_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestXEP0191_GetBlockList(t *testing.T) {

x := New(stm, nil)

storage.Instance().InsertOrUpdateBlockListItems([]model.BlockListItem{{
storage.Instance().InsertBlockListItems([]model.BlockListItem{{
Username: "ortuman",
JID: "hamlet@jackal.im/garden",
}, {
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestXEP191_BlockAndUnblock(t *testing.T) {
require.NotNil(t, item2)

// test full unblock
storage.Instance().InsertOrUpdateBlockListItems([]model.BlockListItem{{
storage.Instance().InsertBlockListItems([]model.BlockListItem{{
Username: "ortuman",
JID: "hamlet@jackal.im/garden",
}, {
Expand Down
2 changes: 1 addition & 1 deletion storage/badgerdb/block_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestBadgerDB_BlockListItems(t *testing.T) {
}
sort.Slice(items, func(i, j int) bool { return items[i].JID < items[j].JID })

err := h.db.InsertOrUpdateBlockListItems(items)
err := h.db.InsertBlockListItems(items)
require.Nil(t, err)

sItems, err := h.db.FetchBlockListItems("ortuman")
Expand Down
6 changes: 3 additions & 3 deletions storage/memstorage/block_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ func TestMockStorageInsertOrUpdateBlockListItems(t *testing.T) {
}
s := New()
s.ActivateMockedError()
require.Equal(t, ErrMockedError, s.InsertOrUpdateBlockListItems(items))
require.Equal(t, ErrMockedError, s.InsertBlockListItems(items))
s.DeactivateMockedError()

s.InsertOrUpdateBlockListItems(items)
s.InsertBlockListItems(items)

s.ActivateMockedError()
_, err := s.FetchBlockListItems("ortuman")
Expand All @@ -41,7 +41,7 @@ func TestMockStorageDeleteBlockListItems(t *testing.T) {
{"ortuman", "juliet@jackal.im"},
}
s := New()
s.InsertOrUpdateBlockListItems(items)
s.InsertBlockListItems(items)

delItems := []model.BlockListItem{{"ortuman", "romeo@jackal.im"}}
s.ActivateMockedError()
Expand Down
4 changes: 2 additions & 2 deletions storage/sql/block_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestMySQLStorageInsertBlockListItems(t *testing.T) {
WillReturnResult(sqlmock.NewResult(0, 1))
mock.ExpectCommit()

err := s.InsertOrUpdateBlockListItems([]model.BlockListItem{{"ortuman", "noelia@jackal.im"}})
err := s.InsertBlockListItems([]model.BlockListItem{{"ortuman", "noelia@jackal.im"}})
require.Nil(t, mock.ExpectationsWereMet())
require.Nil(t, err)

Expand All @@ -29,7 +29,7 @@ func TestMySQLStorageInsertBlockListItems(t *testing.T) {
mock.ExpectExec("INSERT IGNORE INTO blocklist_items (.+)").WillReturnError(errMySQLStorage)
mock.ExpectRollback()

err = s.InsertOrUpdateBlockListItems([]model.BlockListItem{{"ortuman", "noelia@jackal.im"}})
err = s.InsertBlockListItems([]model.BlockListItem{{"ortuman", "noelia@jackal.im"}})
require.Nil(t, mock.ExpectationsWereMet())
require.Equal(t, errMySQLStorage, err)
}
Expand Down
8 changes: 4 additions & 4 deletions stream/c2s/c2s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func TestC2SManager_BlockedJID(t *testing.T) {
Username: "ortuman",
JID: "hamlet@jackal.im/garden",
}}
storage.Instance().InsertOrUpdateBlockListItems(bl1)
storage.Instance().InsertBlockListItems(bl1)
require.False(t, Instance().IsBlockedJID(j2, "ortuman"))
require.True(t, Instance().IsBlockedJID(j3, "ortuman"))

Expand All @@ -248,7 +248,7 @@ func TestC2SManager_BlockedJID(t *testing.T) {
Username: "ortuman",
JID: "hamlet@jackal.im",
}}
storage.Instance().InsertOrUpdateBlockListItems(bl2)
storage.Instance().InsertBlockListItems(bl2)
Instance().ReloadBlockList("ortuman")

require.True(t, Instance().IsBlockedJID(j2, "ortuman"))
Expand All @@ -262,7 +262,7 @@ func TestC2SManager_BlockedJID(t *testing.T) {
Username: "ortuman",
JID: "jackal.im/balcony",
}}
storage.Instance().InsertOrUpdateBlockListItems(bl3)
storage.Instance().InsertBlockListItems(bl3)
Instance().ReloadBlockList("ortuman")

require.True(t, Instance().IsBlockedJID(j2, "ortuman"))
Expand All @@ -276,7 +276,7 @@ func TestC2SManager_BlockedJID(t *testing.T) {
Username: "ortuman",
JID: "jackal.im",
}}
storage.Instance().InsertOrUpdateBlockListItems(bl4)
storage.Instance().InsertBlockListItems(bl4)
Instance().ReloadBlockList("ortuman")

require.True(t, Instance().IsBlockedJID(j2, "ortuman"))
Expand Down

0 comments on commit 76fa47d

Please sign in to comment.