You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.0 KiB
64 lines
1.0 KiB
5 years ago
|
package serializer
|
||
|
|
||
|
import (
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestDecodeUploadPolicy(t *testing.T) {
|
||
|
asserts := assert.New(t)
|
||
|
|
||
|
testCases := []struct {
|
||
|
input string
|
||
|
expectError bool
|
||
|
expectNil bool
|
||
|
expectRes *UploadPolicy
|
||
|
}{
|
||
|
{
|
||
|
"错误的base64字符",
|
||
|
true,
|
||
|
true,
|
||
|
&UploadPolicy{},
|
||
|
},
|
||
|
{
|
||
|
"6ZSZ6K+v55qESlNPTuWtl+espg==",
|
||
|
true,
|
||
|
true,
|
||
|
&UploadPolicy{},
|
||
|
},
|
||
|
{
|
||
|
"e30=",
|
||
|
false,
|
||
|
false,
|
||
|
&UploadPolicy{},
|
||
|
},
|
||
|
{
|
||
5 years ago
|
"eyJjYWxsYmFja191cmwiOiJ0ZXN0In0=",
|
||
5 years ago
|
false,
|
||
|
false,
|
||
5 years ago
|
&UploadPolicy{CallbackURL: "test"},
|
||
5 years ago
|
},
|
||
|
}
|
||
|
|
||
|
for _, testCase := range testCases {
|
||
|
res, err := DecodeUploadPolicy(testCase.input)
|
||
|
if testCase.expectError {
|
||
|
asserts.Error(err)
|
||
|
}
|
||
|
if testCase.expectNil {
|
||
|
asserts.Nil(res)
|
||
|
}
|
||
|
if !testCase.expectNil {
|
||
|
asserts.Equal(testCase.expectRes, res)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
5 years ago
|
|
||
|
func TestUploadPolicy_EncodeUploadPolicy(t *testing.T) {
|
||
|
asserts := assert.New(t)
|
||
|
testPolicy := UploadPolicy{}
|
||
|
res, err := testPolicy.EncodeUploadPolicy()
|
||
|
asserts.NoError(err)
|
||
|
asserts.NotEmpty(res)
|
||
|
}
|