|
@@ -24,7 +24,7 @@ func init() {
|
|
|
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{""}}
|
|
|
+ req := &filesystem.DomainReq{Name: "xzh", MetaFields: []string{"docName", "docSuffix", "docSize"}}
|
|
|
res, err := FileSystem.CreateDomain(ctx, req)
|
|
|
log.Println("err ", err)
|
|
|
log.Println("req ", res)
|
|
@@ -34,7 +34,7 @@ func Test_CreateDomain(t *testing.T) {
|
|
|
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{""}}
|
|
|
+ req := &filesystem.DomainReq{Name: "xzh", MetaFields: []string{"docName", "docSuffix", "docSize"}}
|
|
|
res, err := FileSystem.DeleteDomain(ctx, req)
|
|
|
log.Println("err ", err)
|
|
|
log.Println("req ", res)
|
|
@@ -44,7 +44,7 @@ func Test_DeleteDomain(t *testing.T) {
|
|
|
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{""}}
|
|
|
+ req := &filesystem.LoadFileReq{Domain: "xzh", FileId: "que.txt"}
|
|
|
res, err := FileSystem.DeleteFile(ctx, req)
|
|
|
log.Println("err ", err)
|
|
|
log.Println("req ", res)
|
|
@@ -54,8 +54,8 @@ func Test_DeleteFile(t *testing.T) {
|
|
|
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)
|
|
|
+ req := &filesystem.LoadFileReq{Domain: "xzh", FileId: "que.txt"}
|
|
|
+ res, err := FileSystem.GetFile(ctx, req)
|
|
|
log.Println("err ", err)
|
|
|
log.Println("req ", res)
|
|
|
}
|
|
@@ -64,7 +64,7 @@ func Test_GetFile(t *testing.T) {
|
|
|
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{""}}
|
|
|
+ req := &filesystem.LoadFileReq{Domain: "xzh", FileId: "que.txt"}
|
|
|
res, err := FileSystem.GetFileMeta(ctx, req)
|
|
|
log.Println("err ", err)
|
|
|
log.Println("req ", res)
|
|
@@ -74,7 +74,29 @@ func Test_GetFileMeta(t *testing.T) {
|
|
|
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{""}}
|
|
|
+ file, err := os.Open("./111.txt")
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ defer file.Close()
|
|
|
+ // FileInfo:
|
|
|
+ stats, err := file.Stat()
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ // []byte
|
|
|
+ data := make([]byte, stats.Size())
|
|
|
+ count, err := file.Read(data)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ fmt.Println(count)
|
|
|
+ req := &filesystem.SaveFileReq{
|
|
|
+ Domain: "xzh",
|
|
|
+ FileId: "111.txt",
|
|
|
+ Meta: map[string]string{"docName": "111", "docSuffix": ".txt", "docSize": "1024"},
|
|
|
+ RawFileContent: data,
|
|
|
+ }
|
|
|
res, err := FileSystem.SaveFile(ctx, req)
|
|
|
log.Println("err ", err)
|
|
|
log.Println("req ", res)
|
|
@@ -84,7 +106,11 @@ func Test_SaveFile(t *testing.T) {
|
|
|
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{""}}
|
|
|
+ req := &filesystem.UpdateFileMetaReq{
|
|
|
+ Domain: "xzh",
|
|
|
+ FileId: "que.txt",
|
|
|
+ Meta: map[string]string{"docName": "que", "docSuffix": ".txt", "docSize": "2048"},
|
|
|
+ }
|
|
|
res, err := FileSystem.UpdateFileMeta(ctx, req)
|
|
|
log.Println("err ", err)
|
|
|
log.Println("req ", res)
|