add event store to user tests

This commit is contained in:
Pascal Fischer 2023-04-01 11:11:30 +02:00
parent b2da0ae70f
commit 45badd2c39

View File

@ -4,6 +4,8 @@ import (
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/netbirdio/netbird/management/server/activity"
) )
const ( const (
@ -31,6 +33,7 @@ func TestUser_CreatePAT_ForSameUser(t *testing.T) {
am := DefaultAccountManager{ am := DefaultAccountManager{
Store: store, Store: store,
eventStore: &activity.InMemoryEventStore{},
} }
pat, err := am.CreatePAT(mockAccountID, mockUserID, mockUserID, mockTokenName, mockExpiresIn) pat, err := am.CreatePAT(mockAccountID, mockUserID, mockUserID, mockTokenName, mockExpiresIn)
@ -65,6 +68,7 @@ func TestUser_CreatePAT_ForDifferentUser(t *testing.T) {
am := DefaultAccountManager{ am := DefaultAccountManager{
Store: store, Store: store,
eventStore: &activity.InMemoryEventStore{},
} }
_, err = am.CreatePAT(mockAccountID, mockUserID, mockTargetUserId, mockTokenName, mockExpiresIn) _, err = am.CreatePAT(mockAccountID, mockUserID, mockTargetUserId, mockTokenName, mockExpiresIn)
@ -82,6 +86,7 @@ func TestUser_CreatePAT_WithWrongExpiration(t *testing.T) {
am := DefaultAccountManager{ am := DefaultAccountManager{
Store: store, Store: store,
eventStore: &activity.InMemoryEventStore{},
} }
_, err = am.CreatePAT(mockAccountID, mockUserID, mockUserID, mockTokenName, mockWrongExpiresIn) _, err = am.CreatePAT(mockAccountID, mockUserID, mockUserID, mockTokenName, mockWrongExpiresIn)
@ -99,6 +104,7 @@ func TestUser_CreatePAT_WithEmptyName(t *testing.T) {
am := DefaultAccountManager{ am := DefaultAccountManager{
Store: store, Store: store,
eventStore: &activity.InMemoryEventStore{},
} }
_, err = am.CreatePAT(mockAccountID, mockUserID, mockUserID, mockEmptyTokenName, mockExpiresIn) _, err = am.CreatePAT(mockAccountID, mockUserID, mockUserID, mockEmptyTokenName, mockExpiresIn)
@ -124,6 +130,7 @@ func TestUser_DeletePAT(t *testing.T) {
am := DefaultAccountManager{ am := DefaultAccountManager{
Store: store, Store: store,
eventStore: &activity.InMemoryEventStore{},
} }
err = am.DeletePAT(mockAccountID, mockUserID, mockUserID, mockTokenID1) err = am.DeletePAT(mockAccountID, mockUserID, mockUserID, mockTokenID1)
@ -155,6 +162,7 @@ func TestUser_GetPAT(t *testing.T) {
am := DefaultAccountManager{ am := DefaultAccountManager{
Store: store, Store: store,
eventStore: &activity.InMemoryEventStore{},
} }
pat, err := am.GetPAT(mockAccountID, mockUserID, mockUserID, mockTokenID1) pat, err := am.GetPAT(mockAccountID, mockUserID, mockUserID, mockTokenID1)
@ -189,6 +197,7 @@ func TestUser_GetAllPATs(t *testing.T) {
am := DefaultAccountManager{ am := DefaultAccountManager{
Store: store, Store: store,
eventStore: &activity.InMemoryEventStore{},
} }
pats, err := am.GetAllPATs(mockAccountID, mockUserID, mockUserID) pats, err := am.GetAllPATs(mockAccountID, mockUserID, mockUserID)