f1b8d88d6b
* Improving mattermost auth implementation * Making mattermost-auth based on shared database access * Reverting unneeded changes in the config.json file * Fixing tiny problems * Removing the need of using the mattermost session token * Fixing some bugs and allowing to not-bind the server to any port * Small fix to correctly get the templates * Adding the mattermost-plugin code inside focalboard repo * Adding a not working code part of the cluster websocket communication * Updating the mattermost version * Adding the cluster messages for the websockets * Updating to the new node version * Making it compatible with S3 * Addressing some tiny problems * Fixing server tests * Adds support for MySQL migrations and initialization Co-authored-by: Miguel de la Cruz <miguel@mcrx.me>
46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
package app
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/golang/mock/gomock"
|
|
"github.com/mattermost/focalboard/server/auth"
|
|
"github.com/mattermost/focalboard/server/services/config"
|
|
st "github.com/mattermost/focalboard/server/services/store"
|
|
"github.com/mattermost/focalboard/server/services/store/mockstore"
|
|
"github.com/mattermost/focalboard/server/services/webhook"
|
|
"github.com/mattermost/focalboard/server/ws"
|
|
"github.com/mattermost/mattermost-server/v5/shared/filestore/mocks"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestGetParentID(t *testing.T) {
|
|
ctrl := gomock.NewController(t)
|
|
defer ctrl.Finish()
|
|
cfg := config.Configuration{}
|
|
store := mockstore.NewMockStore(ctrl)
|
|
auth := auth.New(&cfg, store)
|
|
sessionToken := "TESTTOKEN"
|
|
wsserver := ws.NewServer(auth, sessionToken, false)
|
|
webhook := webhook.NewClient(&cfg)
|
|
app := New(&cfg, store, auth, wsserver, &mocks.FileBackend{}, webhook)
|
|
|
|
container := st.Container{
|
|
WorkspaceID: "0",
|
|
}
|
|
t.Run("success query", func(t *testing.T) {
|
|
store.EXPECT().GetParentID(gomock.Eq(container), gomock.Eq("test-id")).Return("test-parent-id", nil)
|
|
result, err := app.GetParentID(container, "test-id")
|
|
require.NoError(t, err)
|
|
require.Equal(t, "test-parent-id", result)
|
|
})
|
|
|
|
t.Run("fail query", func(t *testing.T) {
|
|
store.EXPECT().GetParentID(gomock.Eq(container), gomock.Eq("test-id")).Return("", errors.New("block-not-found"))
|
|
_, err := app.GetParentID(container, "test-id")
|
|
require.Error(t, err)
|
|
require.Equal(t, "block-not-found", err.Error())
|
|
})
|
|
}
|