Test: FileInfo interface

pull/247/head
HFO4 5 years ago
parent 327765a7be
commit 91b873065a

@ -169,7 +169,7 @@ func (file *File) UpdateSize(value uint64) error {
} }
/* /*
FileInfo.FileInfo webdav.FileInfo
*/ */
func (file *File) GetName() string { func (file *File) GetName() string {

@ -6,6 +6,7 @@ import (
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"testing" "testing"
"time"
) )
func TestFile_Create(t *testing.T) { func TestFile_Create(t *testing.T) {
@ -356,3 +357,31 @@ func TestFile_Updates(t *testing.T) {
asserts.NoError(err) asserts.NoError(err)
} }
} }
func TestFile_FileInfoInterface(t *testing.T) {
asserts := assert.New(t)
file := File{
Model: gorm.Model{
UpdatedAt: time.Date(2019, 12, 21, 12, 40, 0, 0, time.UTC),
},
Name: "test_name",
SourceName: "",
UserID: 0,
Size: 10,
PicInfo: "",
FolderID: 0,
PolicyID: 0,
Policy: Policy{},
Position: "/test",
}
name := file.GetName()
asserts.Equal("test_name", name)
size := file.GetSize()
asserts.Equal(uint64(10), size)
asserts.Equal(time.Date(2019, 12, 21, 12, 40, 0, 0, time.UTC), file.ModTime())
asserts.False(file.IsDir())
asserts.Equal("/test", file.GetPosition())
}

@ -7,6 +7,7 @@ import (
"github.com/jinzhu/gorm" "github.com/jinzhu/gorm"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"testing" "testing"
"time"
) )
func TestFolder_Create(t *testing.T) { func TestFolder_Create(t *testing.T) {
@ -506,3 +507,26 @@ func TestFolder_MoveOrCopyFolderTo_Move(t *testing.T) {
asserts.NoError(err) asserts.NoError(err)
} }
} }
func TestFolder_FileInfoInterface(t *testing.T) {
asserts := assert.New(t)
folder := Folder{
Model: gorm.Model{
UpdatedAt: time.Date(2019, 12, 21, 12, 40, 0, 0, time.UTC),
},
Name: "test_name",
ParentID: 0,
OwnerID: 0,
Position: "/test",
}
name := folder.GetName()
asserts.Equal("test_name", name)
size := folder.GetSize()
asserts.Equal(uint64(0), size)
asserts.Equal(time.Date(2019, 12, 21, 12, 40, 0, 0, time.UTC), folder.ModTime())
asserts.True(folder.IsDir())
asserts.Equal("/test", folder.GetPosition())
}

Loading…
Cancel
Save