-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Combine metadata fields * Add TestGetNodeTitleAndGetAllMetadataString * Determine order of getAllMetadataString * Do go fmt * Use github.com/golang/protobuf * Revert "Use github.com/golang/protobuf" This reverts commit 20aa681. * Remove unused function * Refactor (*Node).String()
- Loading branch information
Showing
3 changed files
with
137 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"google.golang.org/genproto/googleapis/spanner/v1" | ||
"google.golang.org/protobuf/types/known/structpb" | ||
) | ||
|
||
func TestNodeString(t *testing.T) { | ||
for _, test := range []struct { | ||
title string | ||
node *Node | ||
want string | ||
}{ | ||
{"Distributed Union with call_type=Local", | ||
&Node{PlanNode: &spanner.PlanNode{ | ||
DisplayName: "Distributed Union", | ||
Metadata: &structpb.Struct{ | ||
Fields: map[string]*structpb.Value{ | ||
"call_type": {Kind: &structpb.Value_StringValue{StringValue: "Local"}}, | ||
"subquery_cluster_node": {Kind: &structpb.Value_StringValue{StringValue: "4"}}, | ||
}, | ||
}, | ||
}}, "Local Distributed Union", | ||
}, | ||
{"Scan with scan_type=IndexScan and Full scan=true", | ||
&Node{PlanNode: &spanner.PlanNode{ | ||
DisplayName: "Scan", | ||
Metadata: &structpb.Struct{ | ||
Fields: map[string]*structpb.Value{ | ||
"scan_type": {Kind: &structpb.Value_StringValue{StringValue: "IndexScan"}}, | ||
"scan_target": {Kind: &structpb.Value_StringValue{StringValue: "SongsBySongName"}}, | ||
"Full scan": {Kind: &structpb.Value_StringValue{StringValue: "true"}}, | ||
}, | ||
}, | ||
}}, "Index Scan (Full scan: true, Index: SongsBySongName)"}, | ||
{ "Scan with scan_type=TableScan", | ||
&Node{PlanNode: &spanner.PlanNode{ | ||
DisplayName: "Scan", | ||
Metadata: &structpb.Struct{ | ||
Fields: map[string]*structpb.Value{ | ||
"scan_type": {Kind: &structpb.Value_StringValue{StringValue: "TableScan"}}, | ||
"scan_target": {Kind: &structpb.Value_StringValue{StringValue: "Songs"}}, | ||
}, | ||
}, | ||
}}, "Table Scan (Table: Songs)"}, | ||
{"Scan with scan_type=BatchScan", | ||
&Node{PlanNode: &spanner.PlanNode{ | ||
DisplayName: "Scan", | ||
Metadata: &structpb.Struct{ | ||
Fields: map[string]*structpb.Value{ | ||
"scan_type": {Kind: &structpb.Value_StringValue{StringValue: "BatchScan"}}, | ||
"scan_target": {Kind: &structpb.Value_StringValue{StringValue: "$v2"}}, | ||
}, | ||
}, | ||
}}, "Batch Scan (Batch: $v2)"}, | ||
{"Sort Limit with call_type=Local", | ||
&Node{PlanNode: &spanner.PlanNode{ | ||
DisplayName: "Sort Limit", | ||
Metadata: &structpb.Struct{ | ||
Fields: map[string]*structpb.Value{ | ||
"call_type": {Kind: &structpb.Value_StringValue{StringValue: "Local"}}, | ||
}, | ||
}, | ||
}}, "Local Sort Limit"}, | ||
{"Sort Limit with call_type=Global", | ||
&Node{PlanNode: &spanner.PlanNode{ | ||
DisplayName: "Sort Limit", | ||
Metadata: &structpb.Struct{ | ||
Fields: map[string]*structpb.Value{ | ||
"call_type": {Kind: &structpb.Value_StringValue{StringValue: "Global"}}, | ||
}, | ||
}, | ||
}}, "Global Sort Limit"}, | ||
{"Aggregate with iterator_type=Stream", | ||
&Node{PlanNode: &spanner.PlanNode{ | ||
DisplayName: "Aggregate", | ||
Metadata: &structpb.Struct{ | ||
Fields: map[string]*structpb.Value{ | ||
"iterator_type": {Kind: &structpb.Value_StringValue{StringValue: "Stream"}}, | ||
}, | ||
}, | ||
}}, "Stream Aggregate"}, | ||
} { | ||
if got := test.node.String(); got != test.want { | ||
t.Errorf("%s: node.String() = %q but want %q", test.title, got, test.want) | ||
} | ||
} | ||
} |