Test: remote handler get & request chan operations / Modify: GET request to remote server should return error http status code

This commit is contained in:
HFO4
2020-01-04 15:17:27 +08:00
parent aeca161186
commit 93dc25aabb
10 changed files with 249 additions and 44 deletions

View File

@@ -56,4 +56,27 @@ func TestFileSystem_Compress(t *testing.T) {
asserts.Contains(zipFile, "archive_")
asserts.Contains(zipFile, "tests")
}
// 上下文取消
{
ctx, cancel := context.WithCancel(context.Background())
cancel()
// 查找压缩父目录
mock.ExpectQuery("SELECT(.+)folders(.+)").
WithArgs(1, 1).
WillReturnRows(sqlmock.NewRows([]string{"id", "name"}).AddRow(1, "parent"))
// 查找顶级待压缩文件
mock.ExpectQuery("SELECT(.+)files(.+)").
WithArgs(1, 1).
WillReturnRows(
sqlmock.NewRows(
[]string{"id", "name", "source_name", "policy_id"}).
AddRow(1, "1.txt", "tests/file1.txt", 1),
)
asserts.NoError(cache.Set("setting_temp_path", "tests", -1))
zipFile, err := fs.Compress(ctx, []uint{1}, []uint{1})
asserts.Error(err)
asserts.Empty(zipFile)
}
}