@@ -110,6 +110,37 @@ func TestContactFieldParamsFromCmd(t *testing.T) {
110110 }
111111 })
112112
113+ t .Run ("valid --prop" , func (t * testing.T ) {
114+ cmd := newFieldCmd (t )
115+ cmd .Flags ().Set ("prop" , "plan=pro" )
116+ cmd .Flags ().Set ("prop" , "score=42" )
117+ params , err := contactFieldParamsFromCmd (cmd )
118+ if err != nil {
119+ t .Fatalf ("unexpected error: %v" , err )
120+ }
121+ if params .ContactProperties ["plan" ] != "pro" || params .ContactProperties ["score" ] != "42" {
122+ t .Errorf ("unexpected contact properties: %v" , params .ContactProperties )
123+ }
124+ })
125+
126+ t .Run ("prop overrides contact-props file" , func (t * testing.T ) {
127+ f := filepath .Join (t .TempDir (), "props.json" )
128+ os .WriteFile (f , []byte (`{"plan":"starter","region":"us"}` ), 0644 )
129+ cmd := newFieldCmd (t )
130+ cmd .Flags ().Set ("contact-props" , f )
131+ cmd .Flags ().Set ("prop" , "plan=pro" )
132+ params , err := contactFieldParamsFromCmd (cmd )
133+ if err != nil {
134+ t .Fatalf ("unexpected error: %v" , err )
135+ }
136+ if params .ContactProperties ["plan" ] != "pro" {
137+ t .Errorf ("expected plan=pro, got %v" , params .ContactProperties ["plan" ])
138+ }
139+ if params .ContactProperties ["region" ] != "us" {
140+ t .Errorf ("expected region=us, got %v" , params .ContactProperties ["region" ])
141+ }
142+ })
143+
113144 t .Run ("nonexistent --contact-props returns error" , func (t * testing.T ) {
114145 cmd := newFieldCmd (t )
115146 cmd .Flags ().Set ("contact-props" , "/nonexistent/path.json" )
@@ -118,6 +149,15 @@ func TestContactFieldParamsFromCmd(t *testing.T) {
118149 t .Fatal ("expected error, got nil" )
119150 }
120151 })
152+
153+ t .Run ("invalid --prop returns error" , func (t * testing.T ) {
154+ cmd := newFieldCmd (t )
155+ cmd .Flags ().Set ("prop" , "missingequals" )
156+ _ , err := contactFieldParamsFromCmd (cmd )
157+ if err == nil {
158+ t .Fatal ("expected error, got nil" )
159+ }
160+ })
121161}
122162
123163func TestRunContactsCreate (t * testing.T ) {
0 commit comments