Test: pkg/task / Fix: failed test due to policy cache

This commit is contained in:
HFO4
2020-02-07 11:47:52 +08:00
parent fc5b7d42c8
commit 4c530a26a0
14 changed files with 309 additions and 57 deletions

View File

@ -12,7 +12,7 @@ import (
func TestGetUserByID(t *testing.T) {
asserts := assert.New(t)
cache.Deletes([]string{"1"}, "policy_")
//找到用户时
userRows := sqlmock.NewRows([]string{"id", "deleted_at", "email", "options", "group_id"}).
AddRow(1, nil, "admin@cloudreve.org", "{}", 1)
@ -104,6 +104,7 @@ func TestNewUser(t *testing.T) {
func TestUser_AfterFind(t *testing.T) {
asserts := assert.New(t)
cache.Deletes([]string{"1"}, "policy_")
policyRows := sqlmock.NewRows([]string{"id", "name"}).
AddRow(1, "默认存储策略")
@ -198,6 +199,7 @@ func TestUser_GetRemainingCapacity(t *testing.T) {
func TestUser_DeductionCapacity(t *testing.T) {
asserts := assert.New(t)
cache.Deletes([]string{"1"}, "policy_")
userRows := sqlmock.NewRows([]string{"id", "deleted_at", "storage", "options", "group_id"}).
AddRow(1, nil, 0, "{}", 1)
mock.ExpectQuery("^SELECT (.+)").WillReturnRows(userRows)