Fix: failed test due to modifications

This commit is contained in:
HFO4
2020-02-27 15:34:16 +08:00
parent c4eada2723
commit 2f1f619f2f
5 changed files with 101 additions and 10 deletions

View File

@@ -84,6 +84,37 @@ func TestHandler_Source(t *testing.T) {
asserts.Contains(res, "api/v3/slave/download/0")
}
// 成功 自定义CDN
{
handler := Driver{
Policy: &model.Policy{Server: "/", BaseURL: "https://cqu.edu.cn"},
AuthInstance: auth.HMACAuth{},
}
file := model.File{
SourceName: "1.txt",
}
ctx := context.WithValue(context.Background(), fsctx.FileModelCtx, file)
res, err := handler.Source(ctx, "", url.URL{}, 10, true, 0)
asserts.NoError(err)
asserts.Contains(res, "api/v3/slave/download/0")
asserts.Contains(res, "https://cqu.edu.cn")
}
// 解析失败 自定义CDN
{
handler := Driver{
Policy: &model.Policy{Server: "/", BaseURL: string(0x7f)},
AuthInstance: auth.HMACAuth{},
}
file := model.File{
SourceName: "1.txt",
}
ctx := context.WithValue(context.Background(), fsctx.FileModelCtx, file)
res, err := handler.Source(ctx, "", url.URL{}, 10, true, 0)
asserts.Error(err)
asserts.Empty(res)
}
// 成功 预览
{
handler := Driver{