MCPcopy Index your code
hub / github.com/labstack/echo / TestParseValue_BindUnmarshaler

Function TestParseValue_BindUnmarshaler

binder_generic_test.go:1246–1278  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1244}
1245
1246func TestParseValue_BindUnmarshaler(t *testing.T) {
1247 exampleTime, _ := time.Parse(time.RFC3339, "2020-12-23T09:45:31+02:00")
1248
1249 var testCases = []struct {
1250 name string
1251 when string
1252 expect Timestamp
1253 expectErr string
1254 }{
1255 {
1256 name: "ok",
1257 when: "2020-12-23T09:45:31+02:00",
1258 expect: Timestamp(exampleTime),
1259 },
1260 {
1261 name: "nok, invalid value",
1262 when: "2020-12-23T09:45:3102:00",
1263 expect: Timestamp{},
1264 expectErr: `failed to parse value, err: parsing time "2020-12-23T09:45:3102:00" as "2006-01-02T15:04:05Z07:00": cannot parse "02:00" as "Z07:00"`,
1265 },
1266 }
1267 for _, tc := range testCases {
1268 t.Run(tc.name, func(t *testing.T) {
1269 v, err := ParseValue[Timestamp](tc.when)
1270 if tc.expectErr != "" {
1271 assert.EqualError(t, err, tc.expectErr)
1272 } else {
1273 assert.NoError(t, err)
1274 }
1275 assert.Equal(t, tc.expect, v)
1276 })
1277 }
1278}
1279
1280func TestParseValue_TextUnmarshaler(t *testing.T) {
1281 var testCases = []struct {

Callers

nothing calls this directly

Calls 1

TimestampTypeAlias · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…