@@ -63,42 +63,46 @@ func TestCollapseToSingleLine(t *testing.T) {
63
63
assert .Equal (t , `hello there aw yeah` , collapseToSingleLine ("hello\n there\t aw\r \n yeah" ))
64
64
}
65
65
66
- func TestTimeToIsoString (t * testing.T ) {
66
+ func TestCriblTimeToGrafanaTime (t * testing.T ) {
67
67
for _ , test := range []struct {
68
68
In interface {}
69
- Expected string
69
+ Expected int64
70
70
}{
71
71
{
72
72
In : nil ,
73
- Expected : "" ,
73
+ Expected : 0 ,
74
74
},
75
75
{
76
76
In : false ,
77
- Expected : "" ,
77
+ Expected : 0 ,
78
78
},
79
79
{
80
80
In : true ,
81
- Expected : "" ,
81
+ Expected : 0 ,
82
82
},
83
83
{
84
84
In : "whatever" ,
85
- Expected : "" ,
85
+ Expected : 0 ,
86
86
},
87
87
{
88
88
In : float64 (1728744793 ),
89
- Expected : "2024-10-12T14:53:13Z" ,
89
+ Expected : 1728744793000000 ,
90
90
},
91
91
{
92
92
In : float64 (1728744793.123 ),
93
- Expected : "2024-10-12T14:53:13.123Z" ,
93
+ Expected : 1728744793123000 ,
94
+ },
95
+ {
96
+ In : float64 (1728744793.123456 ),
97
+ Expected : 1728744793123456 ,
94
98
},
95
99
} {
96
- ok , out := timeToIsoString (test .In )
97
- if len ( test .Expected ) == 0 {
100
+ ok , out := criblTimeToGrafanaTime (test .In )
101
+ if test .Expected == 0 {
98
102
assert .Equal (t , false , ok , fmt .Sprintf ("input %v produced ok=%v, out=%v" , test .In , ok , out ))
99
103
} else {
100
104
assert .Equal (t , true , ok , fmt .Sprintf ("input %v produced ok=%v, out=%v" , test .In , ok , out ))
101
- assert .Equal (t , test .Expected , out , test .In )
105
+ assert .Equal (t , test .Expected , out . UnixMicro () , test .In )
102
106
}
103
107
}
104
108
}
0 commit comments