11package main
22
33import (
4- "io/ioutil "
4+ "os "
55 "testing"
66
77 "github.com/google/go-cmp/cmp"
@@ -67,7 +67,8 @@ func TestRenderTreeUsingTestdataPlans(t *testing.T) {
6767 ID : 7 ,
6868 Text : " +- Index Scan (Index: SingersByFirstLastName)" ,
6969 },
70- }},
70+ },
71+ },
7172 {
7273 /*
7374 Original Query:
@@ -107,7 +108,8 @@ func TestRenderTreeUsingTestdataPlans(t *testing.T) {
107108 ID : 9 ,
108109 Text : " +- Index Scan (Full scan: true, Index: SongsBySingerAlbumSongNameDesc)" ,
109110 },
110- }},
111+ },
112+ },
111113 {
112114 /*
113115 Original Query: https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#array_subqueries
@@ -158,7 +160,8 @@ func TestRenderTreeUsingTestdataPlans(t *testing.T) {
158160 ID : 11 ,
159161 Text : " +- Index Scan (Index: ConcertsBySingerId)" ,
160162 },
161- }},
163+ },
164+ },
162165 {
163166 /*
164167 Original Query: https://cloud.google.com/spanner/docs/query-execution-operators?hl=en#scalar_subqueries
@@ -219,7 +222,8 @@ func TestRenderTreeUsingTestdataPlans(t *testing.T) {
219222 ID : 16 ,
220223 Text : " +- Table Scan (Full scan: true, Table: Songs)" ,
221224 },
222- }},
225+ },
226+ },
223227 {
224228 /*
225229 Original Query:
@@ -367,7 +371,7 @@ func TestRenderTreeUsingTestdataPlans(t *testing.T) {
367371 },
368372 } {
369373 t .Run (test .title , func (t * testing.T ) {
370- b , err := ioutil .ReadFile (test .file )
374+ b , err := os .ReadFile (test .file )
371375 if err != nil {
372376 t .Fatal (err )
373377 }
@@ -480,7 +484,8 @@ func TestRenderTreeWithStats(t *testing.T) {
480484 Execution : "1" ,
481485 LatencyTotal : "1 msec" ,
482486 },
483- }},
487+ },
488+ },
484489 } {
485490 t .Run (test .title , func (t * testing.T ) {
486491 tree := BuildQueryPlanTree (test .plan , 0 )
@@ -494,13 +499,15 @@ func TestRenderTreeWithStats(t *testing.T) {
494499 })
495500 }
496501}
502+
497503func TestNodeString (t * testing.T ) {
498504 for _ , test := range []struct {
499505 title string
500506 node * Node
501507 want string
502508 }{
503- {"Distributed Union with call_type=Local" ,
509+ {
510+ "Distributed Union with call_type=Local" ,
504511 & Node {PlanNode : & spanner.PlanNode {
505512 DisplayName : "Distributed Union" ,
506513 Metadata : mustNewStruct (map [string ]interface {}{
@@ -509,52 +516,64 @@ func TestNodeString(t *testing.T) {
509516 }),
510517 }}, "Local Distributed Union" ,
511518 },
512- {"Scan with scan_type=IndexScan and Full scan=true" ,
519+ {
520+ "Scan with scan_type=IndexScan and Full scan=true" ,
513521 & Node {PlanNode : & spanner.PlanNode {
514522 DisplayName : "Scan" ,
515523 Metadata : mustNewStruct (map [string ]interface {}{
516524 "scan_type" : "IndexScan" ,
517525 "scan_target" : "SongsBySongName" ,
518526 "Full scan" : "true" ,
519527 }),
520- }}, "Index Scan (Full scan: true, Index: SongsBySongName)" },
521- {"Scan with scan_type=TableScan" ,
528+ }}, "Index Scan (Full scan: true, Index: SongsBySongName)" ,
529+ },
530+ {
531+ "Scan with scan_type=TableScan" ,
522532 & Node {PlanNode : & spanner.PlanNode {
523533 DisplayName : "Scan" ,
524534 Metadata : mustNewStruct (map [string ]interface {}{
525535 "scan_type" : "TableScan" ,
526536 "scan_target" : "Songs" ,
527537 }),
528- }}, "Table Scan (Table: Songs)" },
529- {"Scan with scan_type=BatchScan" ,
538+ }}, "Table Scan (Table: Songs)" ,
539+ },
540+ {
541+ "Scan with scan_type=BatchScan" ,
530542 & Node {PlanNode : & spanner.PlanNode {
531543 DisplayName : "Scan" ,
532544 Metadata : mustNewStruct (map [string ]interface {}{
533545 "scan_type" : "BatchScan" ,
534546 "scan_target" : "$v2" ,
535547 }),
536- }}, "Batch Scan (Batch: $v2)" },
537- {"Sort Limit with call_type=Local" ,
548+ }}, "Batch Scan (Batch: $v2)" ,
549+ },
550+ {
551+ "Sort Limit with call_type=Local" ,
538552 & Node {PlanNode : & spanner.PlanNode {
539553 DisplayName : "Sort Limit" ,
540554 Metadata : mustNewStruct (map [string ]interface {}{
541555 "call_type" : "Local" ,
542556 }),
543- }}, "Local Sort Limit" },
544- {"Sort Limit with call_type=Global" ,
557+ }}, "Local Sort Limit" ,
558+ },
559+ {
560+ "Sort Limit with call_type=Global" ,
545561 & Node {PlanNode : & spanner.PlanNode {
546562 DisplayName : "Sort Limit" ,
547563 Metadata : mustNewStruct (map [string ]interface {}{
548564 "call_type" : "Global" ,
549565 }),
550- }}, "Global Sort Limit" },
551- {"Aggregate with iterator_type=Stream" ,
566+ }}, "Global Sort Limit" ,
567+ },
568+ {
569+ "Aggregate with iterator_type=Stream" ,
552570 & Node {PlanNode : & spanner.PlanNode {
553571 DisplayName : "Aggregate" ,
554572 Metadata : mustNewStruct (map [string ]interface {}{
555573 "iterator_type" : "Stream" ,
556574 }),
557- }}, "Stream Aggregate" },
575+ }}, "Stream Aggregate" ,
576+ },
558577 } {
559578 if got := test .node .String (); got != test .want {
560579 t .Errorf ("%s: node.String() = %q but want %q" , test .title , got , test .want )
0 commit comments