12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- package test
- import (
- "context"
- "log"
- "testing"
- "time"
- "app.yhyue.com/moapp/jyfs/rpc/filesystem"
- "app.yhyue.com/moapp/jyfs/rpc/filesystemclient"
- "app.yhyue.com/moapp/jyfs/rpc/internal/config"
- "github.com/tal-tech/go-zero/core/conf"
- "github.com/tal-tech/go-zero/zrpc"
- )
- var C config.Config
- func init() {
- conf.MustLoad("./filesystem.yaml", &C)
- }
- // 创建域
- func Test_CreateDomain(t *testing.T) {
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
- req := &filesystem.DomainReq{Name: "xzh", MetaFields: []string{""}}
- res, err := FileSystem.CreateDomain(ctx, req)
- log.Println("err ", err)
- log.Println("req ", res)
- }
- // 删除域
- func Test_DeleteDomain(t *testing.T) {
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
- req := &filesystem.DomainReq{Name: "xzh", MetaFields: []string{""}}
- res, err := FileSystem.DeleteDomain(ctx, req)
- log.Println("err ", err)
- log.Println("req ", res)
- }
- // 删除文件
- func Test_DeleteFile(t *testing.T) {
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
- req := &filesystem.DomainReq{Name: "xzh", MetaFields: []string{""}}
- res, err := FileSystem.DeleteFile(ctx, req)
- log.Println("err ", err)
- log.Println("req ", res)
- }
- // 获取文件
- func Test_GetFile(t *testing.T) {
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
- req := &filesystem.DomainReq{Name: "xzh", MetaFields: []string{""}}
- res, err := FileSystem.DeleteDomain(ctx, req)
- log.Println("err ", err)
- log.Println("req ", res)
- }
- // 获取文件元数据
- func Test_GetFileMeta(t *testing.T) {
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
- req := &filesystem.DomainReq{Name: "xzh", MetaFields: []string{""}}
- res, err := FileSystem.GetFileMeta(ctx, req)
- log.Println("err ", err)
- log.Println("req ", res)
- }
- // 保存文件
- func Test_SaveFile(t *testing.T) {
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
- req := &filesystem.DomainReq{Name: "xzh", MetaFields: []string{""}}
- res, err := FileSystem.SaveFile(ctx, req)
- log.Println("err ", err)
- log.Println("req ", res)
- }
- // 更新文件元数据
- func Test_UpdateFileMeta(t *testing.T) {
- ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
- FileSystem := filesystemclient.NewFileSystem(zrpc.MustNewClient(C.FileSystemConf))
- req := &filesystem.DomainReq{Name: "xzh", MetaFields: []string{""}}
- res, err := FileSystem.UpdateFileMeta(ctx, req)
- log.Println("err ", err)
- log.Println("req ", res)
- }
|