@@ -63,42 +63,46 @@ func TestCollapseToSingleLine(t *testing.T) {
6363 assert .Equal (t , `hello there aw yeah` , collapseToSingleLine ("hello\n there\t aw\r \n yeah" ))
6464}
6565
66- func TestTimeToIsoString (t * testing.T ) {
66+ func TestCriblTimeToGrafanaTime (t * testing.T ) {
6767 for _ , test := range []struct {
6868 In interface {}
69- Expected string
69+ Expected int64
7070 }{
7171 {
7272 In : nil ,
73- Expected : "" ,
73+ Expected : 0 ,
7474 },
7575 {
7676 In : false ,
77- Expected : "" ,
77+ Expected : 0 ,
7878 },
7979 {
8080 In : true ,
81- Expected : "" ,
81+ Expected : 0 ,
8282 },
8383 {
8484 In : "whatever" ,
85- Expected : "" ,
85+ Expected : 0 ,
8686 },
8787 {
8888 In : float64 (1728744793 ),
89- Expected : "2024-10-12T14:53:13Z" ,
89+ Expected : 1728744793000000 ,
9090 },
9191 {
9292 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 ,
9498 },
9599 } {
96- ok , out := timeToIsoString (test .In )
97- if len ( test .Expected ) == 0 {
100+ ok , out := criblTimeToGrafanaTime (test .In )
101+ if test .Expected == 0 {
98102 assert .Equal (t , false , ok , fmt .Sprintf ("input %v produced ok=%v, out=%v" , test .In , ok , out ))
99103 } else {
100104 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 )
102106 }
103107 }
104108}
0 commit comments