Test: Policy.IsThumbExist / filesystem.AddFile

This commit is contained in:
HFO4
2020-04-22 11:10:43 +08:00
parent 304e7b502c
commit 8c3287d380
2 changed files with 56 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ func TestFileSystem_AddFile(t *testing.T) {
asserts := assert.New(t)
file := local.FileStream{
Size: 5,
Name: "1.txt",
Name: "1.png",
}
folder := model.Folder{
Model: gorm.Model{
@@ -33,6 +33,7 @@ func TestFileSystem_AddFile(t *testing.T) {
ID: 1,
},
Policy: model.Policy{
Type: "cos",
Model: gorm.Model{
ID: 1,
},
@@ -40,7 +41,7 @@ func TestFileSystem_AddFile(t *testing.T) {
},
}
ctx := context.WithValue(context.Background(), fsctx.FileHeaderCtx, file)
ctx = context.WithValue(ctx, fsctx.SavePathCtx, "/Uploads/1_sad.txt")
ctx = context.WithValue(ctx, fsctx.SavePathCtx, "/Uploads/1_sad.png")
_, err := fs.AddFile(ctx, &folder)
@@ -54,7 +55,8 @@ func TestFileSystem_AddFile(t *testing.T) {
asserts.NoError(err)
asserts.NoError(mock.ExpectationsWereMet())
asserts.Equal("/Uploads/1_sad.txt", f.SourceName)
asserts.Equal("/Uploads/1_sad.png", f.SourceName)
asserts.NotEmpty(f.PicInfo)
}
func TestFileSystem_GetContent(t *testing.T) {