Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nikicc committed Feb 10, 2022
1 parent bad54e5 commit 947919a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions openapi/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,20 +741,18 @@ func (c customUnit) ParseExample(v string) (interface{}, error) {
return fmt.Sprintf("%s USD", v), nil
}

type customTime struct {
time.Time
}
type customTime time.Time

func (c customTime) String() string {
return c.Format("2006-01-02T15:04:05")
return time.Time(c).Format("2006-01-02T15:04:05")
}

func (c customTime) ParseExample(v string) (interface{}, error) {
t1, err := time.Parse(time.RFC3339, v)
if err != nil {
return nil, err
}
return customTime{t1}, nil
return customTime(t1), nil
}

// TestGenerator_parseExampleValue tests the parsing of example values.
Expand Down Expand Up @@ -913,13 +911,13 @@ func TestGenerator_parseExampleValue(t *testing.T) {
"mapping to customTime",
reflect.TypeOf(customTime{}),
"2022-02-07T18:00:00+09:00",
customTime{time.Date(2022, time.February, 7, 18, 0, 0, 0, time.FixedZone("", 9*3600))},
customTime(time.Date(2022, time.February, 7, 18, 0, 0, 0, time.FixedZone("", 9*3600))),
},
{
"mapping pointer to customTime",
reflect.PtrTo(reflect.TypeOf(customTime{})),
"2022-02-07T18:00:00+09:00",
customTime{time.Date(2022, time.February, 7, 18, 0, 0, 0, time.FixedZone("", 9*3600))},
customTime(time.Date(2022, time.February, 7, 18, 0, 0, 0, time.FixedZone("", 9*3600))),
},
}

Expand Down

0 comments on commit 947919a

Please sign in to comment.