@@ -16,20 +16,20 @@ import (
1616
1717func TestExpandCreateParamsMapsDurableConfigToSDK (t * testing.T ) {
1818 model := browserPoolModel {
19- Name : types .StringValue ("pool-a" ),
20- Size : types .Int64Value (5 ),
21- ProfileID : types .StringValue ("profile-1" ),
22- RefreshOnProfile : types .BoolValue (false ),
23- ProxyID : types .StringValue ("proxy-1" ),
24- ExtensionIDs : stringListForTest ("ext-b" , "ext-a" ),
25- ChromePolicy : chromePolicyValueForTest (`{"HomepageLocation":"https://example.com"}` ),
26- Viewport : viewportObjectForTest (types .Int64Value (1280 ), types .Int64Value (800 ), types .Int64Value (60 )),
27- Headless : types .BoolValue (true ),
28- KioskMode : types .BoolValue (true ),
29- Stealth : types .BoolValue (false ),
30- StartURL : types .StringValue ("https://start.example" ),
31- TimeoutSeconds : types .Int64Value (90 ),
32- FillRatePerMinute : types .Int64Value (20 ),
19+ Name : types .StringValue ("pool-a" ),
20+ Size : types .Int64Value (5 ),
21+ ProfileID : types .StringValue ("profile-1" ),
22+ RefreshOnProfileUpdate : types .BoolValue (false ),
23+ ProxyID : types .StringValue ("proxy-1" ),
24+ ExtensionIDs : stringListForTest ("ext-b" , "ext-a" ),
25+ ChromePolicy : chromePolicyValueForTest (`{"HomepageLocation":"https://example.com"}` ),
26+ Viewport : viewportObjectForTest (types .Int64Value (1280 ), types .Int64Value (800 ), types .Int64Value (60 )),
27+ Headless : types .BoolValue (true ),
28+ KioskMode : types .BoolValue (true ),
29+ Stealth : types .BoolValue (false ),
30+ StartURL : types .StringValue ("https://start.example" ),
31+ TimeoutSeconds : types .Int64Value (90 ),
32+ FillRatePerMinute : types .Int64Value (20 ),
3333 }
3434
3535 params , diags := expandCreateParams (context .Background (), model )
@@ -62,13 +62,13 @@ func TestExpandCreateParamsMapsDurableConfigToSDK(t *testing.T) {
6262
6363func TestExpandCreateParamsOmitsUnknownServerDefaults (t * testing.T ) {
6464 model := browserPoolModel {
65- Size : types .Int64Value (1 ),
66- RefreshOnProfile : types .BoolUnknown (),
67- Headless : types .BoolUnknown (),
68- KioskMode : types .BoolUnknown (),
69- Stealth : types .BoolUnknown (),
70- TimeoutSeconds : types .Int64Unknown (),
71- FillRatePerMinute : types .Int64Unknown (),
65+ Size : types .Int64Value (1 ),
66+ RefreshOnProfileUpdate : types .BoolUnknown (),
67+ Headless : types .BoolUnknown (),
68+ KioskMode : types .BoolUnknown (),
69+ Stealth : types .BoolUnknown (),
70+ TimeoutSeconds : types .Int64Unknown (),
71+ FillRatePerMinute : types .Int64Unknown (),
7272 }
7373
7474 params , diags := expandCreateParams (context .Background (), model )
@@ -474,6 +474,30 @@ func TestExpandUpdateParamsPreservesExplicitRefreshWhenProfileChanges(t *testing
474474 }
475475}
476476
477+ func TestExpandUpdateParamsPreservesExplicitRefreshWhenProfileIsRemoved (t * testing.T ) {
478+ plan := refreshOnProfileUpdateModel (types .BoolValue (false ))
479+ plan .ProfileID = types .StringNull ()
480+ state := refreshOnProfileUpdateModel (types .BoolValue (false ))
481+ state .ProfileID = types .StringValue ("profile-1" )
482+
483+ params , hasPatch , diags := expandUpdateParams (context .Background (), plan , state )
484+ if diags .HasError () {
485+ t .Fatalf ("unexpected diagnostics: %v" , diags )
486+ }
487+ if ! hasPatch {
488+ t .Fatal ("profile removal did not produce an API patch" )
489+ }
490+
491+ body := marshalSDKParams (t , params )
492+ want := map [string ]any {
493+ "profile" : map [string ]any {"id" : "" },
494+ "refresh_on_profile_update" : false ,
495+ }
496+ if ! jsonEqual (t , body , want ) {
497+ t .Fatalf ("expanded SDK JSON mismatch\n got: %#v\n want: %#v" , body , want )
498+ }
499+ }
500+
477501func TestExpandUpdateParamsLetsAPIChooseRefreshDefaultWhenProfileChanges (t * testing.T ) {
478502 plan := refreshOnProfileUpdateModel (types .BoolUnknown ())
479503 plan .ProfileID = types .StringValue ("profile-2" )
@@ -497,7 +521,7 @@ func TestExpandUpdateParamsLetsAPIChooseRefreshDefaultWhenProfileChanges(t *test
497521
498522func refreshOnProfileUpdateModel (value types.Bool ) browserPoolModel {
499523 model := updateModelForTest ()
500- model .RefreshOnProfile = value
524+ model .RefreshOnProfileUpdate = value
501525 return model
502526}
503527
0 commit comments