aliyunpan/internal/syncdrive/sync_task_test.go

58 lines
1.3 KiB
Go
Raw Normal View History

2022-05-22 16:42:57 +08:00
package syncdrive
import (
2022-05-22 17:47:48 +08:00
"fmt"
"github.com/tickstep/aliyunpan-api/aliyunpan"
"sync"
2022-05-22 16:42:57 +08:00
"testing"
"time"
)
func TestSyncTask(t *testing.T) {
2022-06-01 21:55:03 +08:00
refreshToken := "84c6499b7...9a2fe4f6733c3afd"
2022-05-22 17:47:48 +08:00
webToken, err := aliyunpan.GetAccessTokenFromRefreshToken(refreshToken)
if err != nil {
fmt.Println("get acccess token error")
return
}
// pan client
2023-04-02 09:37:42 +08:00
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
AppId: "25dzX3vbYqktVxyX",
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
UserId: "",
Nonce: 0,
PublicKey: "",
}, aliyunpan.SessionConfig{
DeviceName: "Chrome浏览器",
ModelName: "Windows网页版",
})
2022-05-22 17:47:48 +08:00
user, _ := panClient.GetUserInfo()
2022-05-22 16:42:57 +08:00
task := SyncTask{
2022-06-01 21:55:03 +08:00
Id: "5b2d7c10-e927-4e72-8f9d-5abb3bb04814",
2022-05-22 17:47:48 +08:00
DriveId: user.FileDriveId,
2022-06-01 21:55:03 +08:00
LocalFolderPath: "D:\\smb\\feny\\goprojects\\dev\\NS游戏备份",
2022-05-22 16:42:57 +08:00
PanFolderPath: "/sync_drive",
Mode: "sync",
LastSyncTime: "",
2022-05-24 19:56:06 +08:00
syncDbFolderPath: "D:\\smb\\feny\\goprojects\\dev\\sync_drive",
2022-05-22 17:47:48 +08:00
panClient: panClient,
2022-05-22 16:42:57 +08:00
}
task.Start(StepSyncFile)
2022-05-22 16:42:57 +08:00
//go func() {
// time.Sleep(10 * time.Second)
// task.Stop()
//}()
2022-05-22 17:47:48 +08:00
time.Sleep(60 * time.Second)
2022-05-22 16:42:57 +08:00
task.Stop()
}
func TestSyncLocker(t *testing.T) {
locker := &sync.Mutex{}
locker.Lock()
fmt.Println("lock")
//locker.Unlock()
defer locker.Unlock()
}