| 1234567891011121314151617181920212223242526272829303132333435363738 |
- package server
- import (
- "encoding/binary"
- "file-manger-server/db"
- "testing"
- )
- func TestHandlerReceiveFile(t *testing.T) {
- db.Open()
- bytes := []byte{
- 0x01,
- }
- for i := 0; i < 32; i++ {
- bytes = append(bytes, byte(i))
- }
- var fileName = "test.txt"
- //文件名长度
- bytes = binary.BigEndian.AppendUint32(bytes, uint32(len(fileName)))
- //文件名
- bytes = append(bytes, []byte(fileName)...)
- //文件大小
- bytes = binary.BigEndian.AppendUint64(bytes, uint64(10))
- var path = "./file/" + fileName
- bytes = binary.BigEndian.AppendUint32(bytes, uint32(len(path)))
- //文件路径
- bytes = append(bytes, []byte(path)...)
- //分片大小
- bytes = binary.BigEndian.AppendUint32(bytes, uint32(9))
- //创建时间
- bytes = binary.BigEndian.AppendUint64(bytes, uint64(999))
- //修改时间
- bytes = binary.BigEndian.AppendUint64(bytes, uint64(9999))
- //最后访问时间
- bytes = binary.BigEndian.AppendUint64(bytes, uint64(99999))
- bytes = append(bytes, []byte("1234567890")...)
- HandlerReceiveFile(nil, bytes)
- }
|