2020-03-16 15:34:56 +00:00
|
|
|
package object
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRequest(t *testing.T) {
|
|
|
|
cases := []Request{
|
|
|
|
&PutRequest{},
|
|
|
|
&GetRequest{},
|
|
|
|
&HeadRequest{},
|
|
|
|
&SearchRequest{},
|
|
|
|
&DeleteRequest{},
|
|
|
|
&GetRangeRequest{},
|
|
|
|
&GetRangeHashRequest{},
|
2020-04-03 15:23:24 +00:00
|
|
|
MakePutRequestHeader(nil, nil),
|
2020-04-10 08:30:45 +00:00
|
|
|
MakePutRequestHeader(&Object{}, nil),
|
2020-03-16 15:34:56 +00:00
|
|
|
}
|
|
|
|
|
2020-04-02 12:05:48 +00:00
|
|
|
types := []RequestType{
|
|
|
|
RequestPut,
|
|
|
|
RequestGet,
|
|
|
|
RequestHead,
|
|
|
|
RequestSearch,
|
|
|
|
RequestDelete,
|
|
|
|
RequestRange,
|
|
|
|
RequestRangeHash,
|
2020-04-03 15:23:24 +00:00
|
|
|
RequestPut,
|
2020-04-10 08:30:45 +00:00
|
|
|
RequestPut,
|
2020-04-02 12:05:48 +00:00
|
|
|
}
|
|
|
|
|
2020-03-16 15:34:56 +00:00
|
|
|
for i := range cases {
|
|
|
|
v := cases[i]
|
|
|
|
|
2020-04-10 08:30:45 +00:00
|
|
|
t.Run(fmt.Sprintf("%T_%d", v, i), func(t *testing.T) {
|
2020-03-16 15:34:56 +00:00
|
|
|
require.NotPanics(t, func() { v.CID() })
|
2020-04-02 12:05:48 +00:00
|
|
|
require.Equal(t, types[i], v.Type())
|
2020-03-16 15:34:56 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|