Skip to content

Commit

Permalink
rename as 'IntervalTypeFromString'
Browse files Browse the repository at this point in the history
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
  • Loading branch information
shlomi-noach committed Jan 6, 2025
1 parent 1e9f490 commit f708b8a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions go/mysql/datetime/interval.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ func (itv IntervalType) ToString() string {
}
}

// ParseIntervalType parses a string into an IntervalType. This is the inverse function of IntervalType.ToString().
func ParseIntervalType(s string) IntervalType {
// IntervalTypeFromString parses a string into an IntervalType. This is the inverse function of IntervalType.ToString().
func IntervalTypeFromString(s string) IntervalType {
switch strings.ToLower(s) {
case "year":
return IntervalYear
Expand Down
8 changes: 4 additions & 4 deletions go/mysql/datetime/interval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func TestInRange(t *testing.T) {
}
}

func TestParseIntervalType(t *testing.T) {
func TestIntervalTypeFromString(t *testing.T) {
intervals := []IntervalType{
IntervalMicrosecond,
IntervalSecond,
Expand Down Expand Up @@ -399,18 +399,18 @@ func TestParseIntervalType(t *testing.T) {
t.Run(s, func(t *testing.T) {
require.NotEmpty(t, s)
require.NotEqual(t, "[unknown IntervalType]", s)
parsed := ParseIntervalType(s)
parsed := IntervalTypeFromString(s)
assert.NotEqual(t, IntervalNone, parsed)
assert.Equal(t, interval, parsed)

parsed = ParseIntervalType(strings.ToUpper(s))
parsed = IntervalTypeFromString(strings.ToUpper(s))
assert.NotEqual(t, IntervalNone, parsed)
assert.Equal(t, interval, parsed)
})
}
interval := IntervalType(math.MaxUint8)
s := interval.ToString()
assert.Equal(t, "[unknown IntervalType]", s)
parsed := ParseIntervalType(s)
parsed := IntervalTypeFromString(s)
assert.Equal(t, IntervalNone, parsed)
}

0 comments on commit f708b8a

Please sign in to comment.