1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-11-24 08:22:29 +02:00

Fix #2770: Handle Windows path in import and tests (#2771)

* Upgrade npm in build-ubuntu

* npm i -S moment

* Don't upgrade npm

* macos-latest on build-mac

* Update dev-release.yml

* Support Windows in import archive and tests

* Run CI on Windows too

* CI: Windows SQLite only

* Remove npm ci fromn Windows CI
This commit is contained in:
Chen-I Lim 2022-04-13 10:17:04 -07:00 committed by GitHub
parent cbd03bc612
commit 3264902131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 7 deletions

View File

@ -81,3 +81,23 @@ jobs:
- name: "Test webapp: Cypress"
run: "cd webapp; npm run cypress:ci"
ci-windows-server:
runs-on: windows-2022
strategy:
matrix:
db:
- sqlite
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
- name: "Test server: ${{matrix['db']}}"
run: make server-test-${{matrix['db']}}

View File

@ -2,6 +2,8 @@ package app
import (
"io"
"os"
"path/filepath"
"strings"
"testing"
@ -15,7 +17,6 @@ import (
const (
testFileName = "temp-file-name"
testBoardID = "test-board-id"
testFilePath = "1/test-board-id/temp-file-name"
)
type TestError struct{}
@ -23,6 +24,8 @@ type TestError struct{}
func (err *TestError) Error() string { return "Mocked File backend error" }
func TestGetFileReader(t *testing.T) {
testFilePath := filepath.Join("1", "test-board-id", "temp-file-name")
th, _ := SetupTestHelper(t)
mockedReadCloseSeek := &mocks.ReadCloseSeeker{}
t.Run("should get file reader from filestore successfully", func(t *testing.T) {
@ -105,7 +108,7 @@ func TestGetFileReader(t *testing.T) {
})
t.Run("should move file from old filepath to new filepath, if file doesnot exists in new filepath and workspace id is 0", func(t *testing.T) {
filePath := "0/test-board-id/temp-file-name"
filePath := filepath.Join("0", "test-board-id", "temp-file-name")
workspaceid := "0"
mockedFileBackend := &mocks.FileBackend{}
th.App.filesBackend = mockedFileBackend
@ -140,7 +143,7 @@ func TestGetFileReader(t *testing.T) {
})
t.Run("should return file reader, if file doesnot exists in new filepath and old file path", func(t *testing.T) {
filePath := "0/test-board-id/temp-file-name"
filePath := filepath.Join("0", "test-board-id", "temp-file-name")
fileName := testFileName
workspaceid := "0"
mockedFileBackend := &mocks.FileBackend{}
@ -185,7 +188,7 @@ func TestSaveFile(t *testing.T) {
th.App.filesBackend = mockedFileBackend
writeFileFunc := func(reader io.Reader, path string) int64 {
paths := strings.Split(path, "/")
paths := strings.Split(path, string(os.PathSeparator))
assert.Equal(t, "1", paths[0])
assert.Equal(t, testBoardID, paths[1])
fileName = paths[2]
@ -208,7 +211,7 @@ func TestSaveFile(t *testing.T) {
th.App.filesBackend = mockedFileBackend
writeFileFunc := func(reader io.Reader, path string) int64 {
paths := strings.Split(path, "/")
paths := strings.Split(path, string(os.PathSeparator))
assert.Equal(t, "1", paths[0])
assert.Equal(t, "test-board-id", paths[1])
assert.Equal(t, "jpg", strings.Split(paths[2], ".")[1])
@ -232,7 +235,7 @@ func TestSaveFile(t *testing.T) {
mockedError := &TestError{}
writeFileFunc := func(reader io.Reader, path string) int64 {
paths := strings.Split(path, "/")
paths := strings.Split(path, string(os.PathSeparator))
assert.Equal(t, "1", paths[0])
assert.Equal(t, "test-board-id", paths[1])
assert.Equal(t, "jpg", strings.Split(paths[2], ".")[1])

View File

@ -58,7 +58,7 @@ func (a *App) ImportArchive(r io.Reader, opt model.ImportArchiveOptions) error {
return err
}
dir, filename := path.Split(hdr.Name)
dir, filename := filepath.Split(hdr.Name)
dir = path.Clean(dir)
switch filename {