Atlas › Test

random_string

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

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

Co-introduced tests

1 other test enter at the same concept.

Covered source

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

go.temporal.io/server/common/sqlquery/query.go 13 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 query.go
31 > }
32 return parsedTime, 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 query.go
38 > }
39 return "", fmt.Errorf("value %s is not a string value", s)
40 }