mirror of
https://github.com/gin-gonic/gin.git
synced 2026-07-14 15:11:18 +08:00
Compare commits
2 Commits
2061c2de73
...
a9d6977179
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9d6977179 | ||
|
|
bee5bd3131 |
@ -34,6 +34,7 @@ func (m *mockTextUnmarshaler) UnmarshalText(text []byte) error {
|
||||
return m.returnError
|
||||
}
|
||||
|
||||
// TestTrySetByInterface_WithBindUnmarshaler tests successful binding with bindUnmarshaler
|
||||
func TestTrySetByInterface_WithBindUnmarshaler(t *testing.T) {
|
||||
api := bindingApi{}
|
||||
mock := &mockBindUnmarshaler{}
|
||||
@ -46,6 +47,7 @@ func TestTrySetByInterface_WithBindUnmarshaler(t *testing.T) {
|
||||
require.Equal(t, inputVal, mock.receivedParam)
|
||||
}
|
||||
|
||||
// TestTrySetByInterface_WithBindUnmarshalerError tests error handling from bindUnmarshaler
|
||||
func TestTrySetByInterface_WithBindUnmarshalerError(t *testing.T) {
|
||||
api := bindingApi{}
|
||||
expectedErr := errors.New("unmarshal error")
|
||||
@ -58,6 +60,7 @@ func TestTrySetByInterface_WithBindUnmarshalerError(t *testing.T) {
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
// TestTrySetByInterface_WithTextUnmarshaler tests encoding.TextUnmarshaler
|
||||
func TestTrySetByInterface_WithTextUnmarshaler(t *testing.T) {
|
||||
api := bindingApi{}
|
||||
mock := &mockTextUnmarshaler{}
|
||||
@ -70,6 +73,7 @@ func TestTrySetByInterface_WithTextUnmarshaler(t *testing.T) {
|
||||
require.Equal(t, []byte(inputVal), mock.receivedText)
|
||||
}
|
||||
|
||||
// TestTrySetByInterface_WithTextUnmarshalerError tests error handling from TextUnmarshaler
|
||||
func TestTrySetByInterface_WithTextUnmarshalerError(t *testing.T) {
|
||||
api := bindingApi{}
|
||||
expectedErr := errors.New("text unmarshal error")
|
||||
@ -82,6 +86,7 @@ func TestTrySetByInterface_WithTextUnmarshalerError(t *testing.T) {
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
// TestTrySetByInterface_WithTimeTime tests that time.Time is skipped
|
||||
func TestTrySetByInterface_WithTimeTime(t *testing.T) {
|
||||
api := bindingApi{}
|
||||
now := time.Now()
|
||||
@ -138,6 +143,7 @@ func (m *mockBothInterfaces) UnmarshalText(text []byte) error {
|
||||
|
||||
var _ encoding.TextUnmarshaler = (*mockBothInterfaces)(nil)
|
||||
|
||||
// TestTrySetByInterface_PriorityBindUnmarshaler tests bindUnmarshaler takes priority
|
||||
func TestTrySetByInterface_PriorityBindUnmarshaler(t *testing.T) {
|
||||
api := bindingApi{}
|
||||
mock := &mockBothInterfaces{}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user