|
|
@ -2,6 +2,7 @@ package onedrive
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"io"
|
|
|
|
"io"
|
|
|
|
"io/ioutil"
|
|
|
|
"io/ioutil"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
@ -150,6 +151,21 @@ func TestDriver_Source(t *testing.T) {
|
|
|
|
asserts.Equal("res", res)
|
|
|
|
asserts.Equal("res", res)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 命中缓存 上下文存在文件 成功
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
file := model.File{}
|
|
|
|
|
|
|
|
file.ID = 1
|
|
|
|
|
|
|
|
file.UpdatedAt = time.Now()
|
|
|
|
|
|
|
|
ctx := context.WithValue(context.Background(), fsctx.FileModelCtx, file)
|
|
|
|
|
|
|
|
handler.Client.Credential.ExpiresIn = time.Now().Add(time.Duration(100) * time.Hour).Unix()
|
|
|
|
|
|
|
|
handler.Client.Credential.AccessToken = "1"
|
|
|
|
|
|
|
|
cache.Set(fmt.Sprintf("onedrive_source_file_%d_1", file.UpdatedAt.Unix()), "res", 0)
|
|
|
|
|
|
|
|
res, err := handler.Source(ctx, "123.jpg", url.URL{}, 0, true, 0)
|
|
|
|
|
|
|
|
cache.Deletes([]string{"0_123.jpg"}, "onedrive_source_")
|
|
|
|
|
|
|
|
asserts.NoError(err)
|
|
|
|
|
|
|
|
asserts.Equal("res", res)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 成功
|
|
|
|
// 成功
|
|
|
|
{
|
|
|
|
{
|
|
|
|
handler.Client.Credential.ExpiresIn = time.Now().Add(time.Duration(100) * time.Hour).Unix()
|
|
|
|
handler.Client.Credential.ExpiresIn = time.Now().Add(time.Duration(100) * time.Hour).Unix()
|
|
|
|