11package structpath
22
33import (
4+ "reflect"
45 "testing"
56
6- "github.com/databricks/cli/libs/structdiff/structtag"
77 "github.com/stretchr/testify/assert"
88)
99
@@ -42,28 +42,28 @@ func TestPathNode(t *testing.T) {
4242 },
4343 {
4444 name : "struct field with JSON tag" ,
45- node : NewStructField (nil , structtag . JSONTag ( "json_name" ), "GoFieldName" ),
45+ node : NewStructField (nil , reflect . StructTag ( `json: "json_name"` ), "GoFieldName" ),
4646 String : ".json_name" ,
4747 DynPath : "json_name" ,
4848 Field : "json_name" ,
4949 },
5050 {
5151 name : "struct field without JSON tag (fallback to Go name)" ,
52- node : NewStructField (nil , structtag . JSONTag ("" ), "GoFieldName" ),
52+ node : NewStructField (nil , reflect . StructTag ("" ), "GoFieldName" ),
5353 String : ".GoFieldName" ,
5454 DynPath : "GoFieldName" ,
5555 Field : "GoFieldName" ,
5656 },
5757 {
5858 name : "struct field with dash JSON tag" ,
59- node : NewStructField (nil , structtag . JSONTag ( "-" ), "GoFieldName" ),
59+ node : NewStructField (nil , reflect . StructTag ( `json: "-"` ), "GoFieldName" ),
6060 String : ".-" ,
6161 DynPath : "-" ,
6262 Field : "-" ,
6363 },
6464 {
6565 name : "struct field with JSON tag options" ,
66- node : NewStructField (nil , structtag . JSONTag ( "lazy_field,omitempty" ), "LazyField" ),
66+ node : NewStructField (nil , reflect . StructTag ( `json: "lazy_field,omitempty"` ), "LazyField" ),
6767 String : ".lazy_field" ,
6868 DynPath : "lazy_field" ,
6969 Field : "lazy_field" ,
@@ -85,21 +85,21 @@ func TestPathNode(t *testing.T) {
8585 // Two node tests
8686 {
8787 name : "struct field -> array index" ,
88- node : NewIndex (NewStructField (nil , structtag . JSONTag ( "items" ), "Items" ), 3 ),
88+ node : NewIndex (NewStructField (nil , reflect . StructTag ( `json: "items"` ), "Items" ), 3 ),
8989 String : ".items[3]" ,
9090 DynPath : "items[3]" ,
9191 Index : 3 ,
9292 },
9393 {
9494 name : "struct field -> map key" ,
95- node : NewMapKey (NewStructField (nil , structtag . JSONTag ( "config" ), "Config" ), "database" ),
95+ node : NewMapKey (NewStructField (nil , reflect . StructTag ( `json: "config"` ), "Config" ), "database" ),
9696 String : `.config["database"]` ,
9797 DynPath : "config.database" ,
9898 MapKey : "database" ,
9999 },
100100 {
101101 name : "struct field -> struct field" ,
102- node : NewStructField (NewStructField (nil , structtag . JSONTag ( "user" ), "User" ), structtag . JSONTag ( "name" ), "Name" ),
102+ node : NewStructField (NewStructField (nil , reflect . StructTag ( `json: "user"` ), "User" ), reflect . StructTag ( `json: "name"` ), "Name" ),
103103 String : ".user.name" ,
104104 DynPath : "user.name" ,
105105 Field : "name" ,
@@ -113,14 +113,14 @@ func TestPathNode(t *testing.T) {
113113 },
114114 {
115115 name : "map key -> struct field" ,
116- node : NewStructField (NewMapKey (nil , "primary" ), structtag . JSONTag ( "host" ), "Host" ),
116+ node : NewStructField (NewMapKey (nil , "primary" ), reflect . StructTag ( `json: "host"` ), "Host" ),
117117 String : `["primary"].host` ,
118118 DynPath : `primary.host` ,
119119 Field : "host" ,
120120 },
121121 {
122122 name : "array index -> struct field" ,
123- node : NewStructField (NewIndex (nil , 2 ), structtag . JSONTag ( "id" ), "ID" ),
123+ node : NewStructField (NewIndex (nil , 2 ), reflect . StructTag ( `json: "id"` ), "ID" ),
124124 String : "[2].id" ,
125125 Field : "id" ,
126126 },
@@ -133,21 +133,21 @@ func TestPathNode(t *testing.T) {
133133 },
134134 {
135135 name : "struct field without JSON tag -> struct field with JSON tag" ,
136- node : NewStructField (NewStructField (nil , structtag . JSONTag ("" ), "Parent" ), structtag . JSONTag ( "child_name" ), "ChildName" ),
136+ node : NewStructField (NewStructField (nil , reflect . StructTag ("" ), "Parent" ), reflect . StructTag ( `json: "child_name"` ), "ChildName" ),
137137 String : ".Parent.child_name" ,
138138 DynPath : "Parent.child_name" ,
139139 Field : "child_name" ,
140140 },
141141 {
142142 name : "any key" ,
143- node : NewAnyKey (NewStructField (nil , structtag . JSONTag ("" ), "Parent" )),
143+ node : NewAnyKey (NewStructField (nil , reflect . StructTag ("" ), "Parent" )),
144144 String : ".Parent[*]" ,
145145 DynPath : "Parent.*" ,
146146 AnyKey : true ,
147147 },
148148 {
149149 name : "any index" ,
150- node : NewAnyIndex (NewStructField (nil , structtag . JSONTag ("" ), "Parent" )),
150+ node : NewAnyIndex (NewStructField (nil , reflect . StructTag ("" ), "Parent" )),
151151 String : ".Parent[*]" ,
152152 DynPath : "Parent[*]" ,
153153 AnyIndex : true ,
0 commit comments