Feat: generate upload server url from policy

This commit is contained in:
HFO4
2020-01-13 10:03:45 +08:00
parent 6b6bfb4c6b
commit 37e78cb39b
3 changed files with 44 additions and 1 deletions

View File

@@ -141,3 +141,26 @@ func TestPolicy_IsDirectlyPreview(t *testing.T) {
policy.Type = "remote"
asserts.False(policy.IsDirectlyPreview())
}
func TestPolicy_GetUploadURL(t *testing.T) {
asserts := assert.New(t)
// 本地
{
policy := Policy{Type: "local", Server: "http://127.0.0.1"}
asserts.Equal("http://127.0.0.1/api/v3/file/upload", policy.GetUploadURL())
}
// 远程
{
policy := Policy{Type: "remote", Server: "http://127.0.0.1"}
asserts.Equal("http://127.0.0.1/api/v3/slave/upload", policy.GetUploadURL())
}
// 未知
{
policy := Policy{Type: "unknown", Server: "http://127.0.0.1"}
asserts.Equal("http://127.0.0.1", policy.GetUploadURL())
}
}