Atlas › Test

acceptance

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

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

Covered source

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

go.temporal.io/server/common/sqlquery/query.go 12 covered LOC · 6 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
27 }
28 > parsedTime, err := time.Parse(DefaultDateTimeFormat, timestampStr) query.go
29 > if err != nil {
30 return time.Time{}, err
31 }
32 > return parsedTime, nil query.go
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 query.go
38 > }
39 return "", fmt.Errorf("value %s is not a string value", s)
40 }