90f6389745
* Added getWorkspaceUsers API * Integrated workspace user API in UI * Integrated workspace user API in UI * Added toto for implementation slot * Implemenmted getWorkspaceUSers to get data from Focalboard DB * Updated store mocks * Made select styles a shared constant * Removed unwanted diffs * Removed unwanted diffs * Updated snapshots for new property type * Added user store test * Added missing copyright notice * Returning error if no users found to retain original behavior * Minor fixes and added tests * Minor fixes * Used React context for workspace users * Used useContext hook, and added additional user ID -> user context to avoid that computation by all componnets * Mergerd both workspace user contextx * Minor review fix
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package storetests
|
|
|
|
import (
|
|
"database/sql"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/mattermost/focalboard/server/model"
|
|
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/mattermost/focalboard/server/services/store"
|
|
)
|
|
|
|
func StoreTestUserStore(t *testing.T, setup func(t *testing.T) (store.Store, func())) {
|
|
t.Run("SetGetSystemSettings", func(t *testing.T) {
|
|
store, tearDown := setup(t)
|
|
defer tearDown()
|
|
testGetWorkspaceUsers(t, store)
|
|
})
|
|
}
|
|
|
|
func testGetWorkspaceUsers(t *testing.T, store store.Store) {
|
|
t.Run("GetWorkspaceUSers", func(t *testing.T) {
|
|
users, err := store.GetUsersByWorkspace("workspace_1")
|
|
require.Equal(t, 0, len(users))
|
|
require.Equal(t, sql.ErrNoRows, err)
|
|
|
|
userID := uuid.New().String()
|
|
|
|
err = store.CreateUser(&model.User{
|
|
ID: userID,
|
|
Username: "darth.vader",
|
|
})
|
|
require.Nil(t, err)
|
|
|
|
defer store.UpdateUser(&model.User{
|
|
ID: userID,
|
|
DeleteAt: time.Now().Unix(),
|
|
})
|
|
|
|
users, err = store.GetUsersByWorkspace("workspace_1")
|
|
require.Equal(t, 1, len(users))
|
|
require.Equal(t, "darth.vader", users[0].Username)
|
|
require.Nil(t, err)
|
|
})
|
|
}
|