mirror of
https://github.com/tickstep/aliyunpan.git
synced 2025-02-02 21:27:15 +08:00
remove test code
This commit is contained in:
parent
25202861c5
commit
5cab8cc6a5
@ -2,64 +2,15 @@ package syncdrive
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/tickstep/aliyunpan-api/aliyunpan"
|
|
||||||
"github.com/tickstep/aliyunpan-api/aliyunpan/apierror"
|
|
||||||
"github.com/tickstep/aliyunpan/internal/utils"
|
"github.com/tickstep/aliyunpan/internal/utils"
|
||||||
"github.com/tickstep/library-go/logger"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPanSyncDb(t *testing.T) {
|
|
||||||
// get access token
|
|
||||||
refreshToken := "d77420e4daa...9d384d7c44508"
|
|
||||||
webToken, err := aliyunpan.GetAccessTokenFromRefreshToken(refreshToken)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("get acccess token error")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// pan client
|
|
||||||
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
|
|
||||||
AppId: "25dzX3vbYqktVxyX",
|
|
||||||
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
|
|
||||||
UserId: "",
|
|
||||||
Nonce: 0,
|
|
||||||
PublicKey: "",
|
|
||||||
}, aliyunpan.SessionConfig{
|
|
||||||
DeviceName: "Chrome浏览器",
|
|
||||||
ModelName: "Windows网页版",
|
|
||||||
})
|
|
||||||
|
|
||||||
// get user info
|
|
||||||
ui, err := panClient.GetUserInfo()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("get user info error")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Println("当前登录用户:" + ui.Nickname)
|
|
||||||
|
|
||||||
b := NewPanSyncDb("D:\\smb\\feny\\goprojects\\dev\\pan.db")
|
|
||||||
b.Open()
|
|
||||||
defer b.Close()
|
|
||||||
// do some file operation
|
|
||||||
panClient.FilesDirectoriesRecurseList(ui.FileDriveId, "/Parallels Desktop", func(depth int, _ string, fd *aliyunpan.FileEntity, apiError *apierror.ApiError) bool {
|
|
||||||
if apiError != nil {
|
|
||||||
logger.Verbosef("%s\n", apiError)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
fmt.Println("add file:" + fd.String())
|
|
||||||
b.Add(NewPanFileItem(fd))
|
|
||||||
time.Sleep(2 * time.Second)
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGet(t *testing.T) {
|
func TestGet(t *testing.T) {
|
||||||
b := NewPanSyncDb("D:\\smb\\feny\\goprojects\\dev\\pan.db")
|
b := NewPanSyncDb("D:\\smb\\feny\\goprojects\\dev\\pan.db")
|
||||||
b.Open()
|
b.Open()
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
package syncdrive
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/tickstep/aliyunpan-api/aliyunpan"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestStart(t *testing.T) {
|
|
||||||
refreshToken := "1640cc2d4ea...6b8ccb4d6242161a7"
|
|
||||||
webToken, err := aliyunpan.GetAccessTokenFromRefreshToken(refreshToken)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("get acccess token error")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// pan client
|
|
||||||
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
|
|
||||||
AppId: "25dzX3vbYqktVxyX",
|
|
||||||
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
|
|
||||||
UserId: "",
|
|
||||||
Nonce: 0,
|
|
||||||
PublicKey: "",
|
|
||||||
}, aliyunpan.SessionConfig{
|
|
||||||
DeviceName: "Chrome浏览器",
|
|
||||||
ModelName: "Windows网页版",
|
|
||||||
})
|
|
||||||
user, _ := panClient.GetUserInfo()
|
|
||||||
|
|
||||||
manager := NewSyncTaskManager(
|
|
||||||
nil,
|
|
||||||
user.FileDriveId,
|
|
||||||
panClient,
|
|
||||||
"D:\\smb\\feny\\goprojects\\dev\\sync_drive",
|
|
||||||
SyncOption{},
|
|
||||||
)
|
|
||||||
|
|
||||||
manager.Start(nil, StepSyncFile)
|
|
||||||
time.Sleep(30 * time.Minute)
|
|
||||||
manager.Stop(StepSyncFile)
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
package syncdrive
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/tickstep/aliyunpan-api/aliyunpan"
|
|
||||||
"sync"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSyncTask(t *testing.T) {
|
|
||||||
refreshToken := "84c6499b7...9a2fe4f6733c3afd"
|
|
||||||
webToken, err := aliyunpan.GetAccessTokenFromRefreshToken(refreshToken)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("get acccess token error")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// pan client
|
|
||||||
panClient := aliyunpan.NewPanClient(*webToken, aliyunpan.AppLoginToken{}, aliyunpan.AppConfig{
|
|
||||||
AppId: "25dzX3vbYqktVxyX",
|
|
||||||
DeviceId: "E75459EXhOTkI5ZI6S3qDHA3",
|
|
||||||
UserId: "",
|
|
||||||
Nonce: 0,
|
|
||||||
PublicKey: "",
|
|
||||||
}, aliyunpan.SessionConfig{
|
|
||||||
DeviceName: "Chrome浏览器",
|
|
||||||
ModelName: "Windows网页版",
|
|
||||||
})
|
|
||||||
user, _ := panClient.GetUserInfo()
|
|
||||||
task := SyncTask{
|
|
||||||
Id: "5b2d7c10-e927-4e72-8f9d-5abb3bb04814",
|
|
||||||
DriveId: user.FileDriveId,
|
|
||||||
LocalFolderPath: "D:\\smb\\feny\\goprojects\\dev\\NS游戏备份",
|
|
||||||
PanFolderPath: "/sync_drive",
|
|
||||||
Mode: "sync",
|
|
||||||
LastSyncTime: "",
|
|
||||||
|
|
||||||
syncDbFolderPath: "D:\\smb\\feny\\goprojects\\dev\\sync_drive",
|
|
||||||
panClient: panClient,
|
|
||||||
}
|
|
||||||
task.Start(StepSyncFile)
|
|
||||||
//go func() {
|
|
||||||
// time.Sleep(10 * time.Second)
|
|
||||||
// task.Stop()
|
|
||||||
//}()
|
|
||||||
time.Sleep(60 * time.Second)
|
|
||||||
task.Stop()
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSyncLocker(t *testing.T) {
|
|
||||||
locker := &sync.Mutex{}
|
|
||||||
locker.Lock()
|
|
||||||
fmt.Println("lock")
|
|
||||||
//locker.Unlock()
|
|
||||||
defer locker.Unlock()
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user