Added tests to load files
continuous-integration/drone/pr Build is failing
Details
continuous-integration/drone/pr Build is failing
Details
This commit is contained in:
parent
1d3defe630
commit
74a17bfe92
|
@ -0,0 +1,61 @@
|
|||
// Copyright 2019 Vikunja and contriubtors. All rights reserved.
|
||||
//
|
||||
// This file is part of Vikunja.
|
||||
//
|
||||
// Vikunja is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Vikunja is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Vikunja. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package files
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCreate(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestFile_Delete(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
func TestFile_LoadFileByID(t *testing.T) {
|
||||
t.Run("Normal", func(t *testing.T) {
|
||||
f := &File{ID: 1}
|
||||
err := f.LoadFileByID()
|
||||
assert.NoError(t, err)
|
||||
})
|
||||
t.Run("Nonexisting", func(t *testing.T) {
|
||||
f := &File{ID: 9999}
|
||||
err := f.LoadFileByID()
|
||||
assert.Error(t, err)
|
||||
assert.True(t, os.IsNotExist(err))
|
||||
})
|
||||
}
|
||||
|
||||
func TestFile_LoadFileMetaByID(t *testing.T) {
|
||||
t.Run("Normal", func(t *testing.T) {
|
||||
f := &File{ID: 1}
|
||||
err := f.LoadFileMetaByID()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "test", f.Name)
|
||||
})
|
||||
t.Run("Nonexisting", func(t *testing.T) {
|
||||
f := &File{ID: 9999}
|
||||
err := f.LoadFileMetaByID()
|
||||
assert.Error(t, err)
|
||||
assert.True(t, IsErrFileDoesNotExist(err))
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue