Feat: user storage pack

This commit is contained in:
HFO4
2020-01-14 10:32:54 +08:00
parent f3e78ec4ff
commit 5be7ec98c1
11 changed files with 148 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ package serializer
import (
model "github.com/HFO4/cloudreve/models"
"github.com/HFO4/cloudreve/pkg/cache"
"github.com/stretchr/testify/assert"
"testing"
)
@@ -27,6 +28,7 @@ func TestBuildUserResponse(t *testing.T) {
func TestBuildUserStorageResponse(t *testing.T) {
asserts := assert.New(t)
cache.Set("pack_size_0", uint64(0), 0)
{
user := model.User{
@@ -58,4 +60,15 @@ func TestBuildUserStorageResponse(t *testing.T) {
asserts.Equal(uint64(10), res.Data.(storage).Total)
asserts.Equal(uint64(0), res.Data.(storage).Free)
}
{
cache.Set("pack_size_0", uint64(1), 0)
user := model.User{
Storage: 6,
Group: model.Group{MaxStorage: 10},
}
res := BuildUserStorageResponse(user)
asserts.Equal(uint64(6), res.Data.(storage).Used)
asserts.Equal(uint64(11), res.Data.(storage).Total)
asserts.Equal(uint64(5), res.Data.(storage).Free)
}
}