Atlas › Test

NoQuotes

Exact test identity: go.temporal.io/server/common/sqlquery/TestConvertToTime/NoQuotes

Package
go.temporal.io/server/common/sqlquery
Suite / test hierarchy
TestConvertToTime/NoQuotes
Test
NoQuotes
Introduced at
query.go ×1 Frontier kind: Joint frontier
Covered ranges
5
Covered lines
10
Covered files
1

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/sqlquery/query.go 10 covered LOC · 5 ranges

Open complete file

17 )
18
19 > func ConvertToTime(timeStr string) (time.Time, error) { query.go
20 > ts, err := strconv.ParseInt(timeStr, 10, 64)
21 > if err == nil {
22 return timestamp.UnixOrZeroTime(ts), nil
23 }
24 > timestampStr, err := ExtractStringValue(timeStr) query.go
25 > if err != nil {
26 > return time.Time{}, err query.go
27 > }
28 parsedTime, err := time.Parse(DefaultDateTimeFormat, timestampStr)
29 if err != nil {
33 }
34
35 > func ExtractStringValue(s string) (string, error) { query.go
36 > if len(s) >= 2 && s[0] == '\'' && s[len(s)-1] == '\'' {
37 return s[1 : len(s)-1], nil
38 }
39 > return "", fmt.Errorf("value %s is not a string value", s) query.go
40 }
41