@@ -22,7 +22,7 @@ func TestProxyCreate_Datacenter_Success(t *testing.T) {
2222 // Check config
2323 dcConfig := body .Config .OfProxyNewsConfigDatacenterProxyConfig
2424 assert .NotNil (t , dcConfig )
25- assert .Equal (t , "US" , dcConfig .Country )
25+ assert .Equal (t , "US" , dcConfig .Country . Value )
2626
2727 return & kernel.ProxyNewResponse {
2828 ID : "dc-new" ,
@@ -48,19 +48,38 @@ func TestProxyCreate_Datacenter_Success(t *testing.T) {
4848 assert .Contains (t , output , "My DC Proxy" )
4949}
5050
51- func TestProxyCreate_Datacenter_MissingCountry (t * testing.T ) {
52- _ = captureOutput (t )
53- fake := & FakeProxyService {}
51+ func TestProxyCreate_Datacenter_WithoutCountry (t * testing.T ) {
52+ buf := captureOutput (t )
53+
54+ fake := & FakeProxyService {
55+ NewFunc : func (ctx context.Context , body kernel.ProxyNewParams , opts ... option.RequestOption ) (* kernel.ProxyNewResponse , error ) {
56+ // Verify the request
57+ assert .Equal (t , kernel .ProxyNewParamsTypeDatacenter , body .Type )
58+ assert .Equal (t , "My DC Proxy" , body .Name .Value )
59+
60+ // Check config - country should not be set (it should be zero/nil)
61+ dcConfig := body .Config .OfProxyNewsConfigDatacenterProxyConfig
62+ assert .NotNil (t , dcConfig )
63+
64+ return & kernel.ProxyNewResponse {
65+ ID : "dc-new" ,
66+ Name : "My DC Proxy" ,
67+ Type : kernel .ProxyNewResponseTypeDatacenter ,
68+ }, nil
69+ },
70+ }
5471
5572 p := ProxyCmd {proxies : fake }
5673 err := p .Create (context .Background (), ProxyCreateInput {
5774 Name : "My DC Proxy" ,
5875 Type : "datacenter" ,
59- // Missing required Country
76+ // Country is now optional
6077 })
6178
62- assert .Error (t , err )
63- assert .Contains (t , err .Error (), "--country is required for datacenter proxy type" )
79+ assert .NoError (t , err )
80+ output := buf .String ()
81+ assert .Contains (t , output , "Creating datacenter proxy" )
82+ assert .Contains (t , output , "Successfully created proxy" )
6483}
6584
6685func TestProxyCreate_Residential_Success (t * testing.T ) {
@@ -315,7 +334,7 @@ func TestProxyCreate_ISP_Success(t *testing.T) {
315334 // Verify ISP config
316335 ispConfig := body .Config .OfProxyNewsConfigIspProxyConfig
317336 assert .NotNil (t , ispConfig )
318- assert .Equal (t , "EU" , ispConfig .Country )
337+ assert .Equal (t , "EU" , ispConfig .Country . Value )
319338
320339 return & kernel.ProxyNewResponse {
321340 ID : "isp-new" ,
@@ -337,3 +356,33 @@ func TestProxyCreate_ISP_Success(t *testing.T) {
337356 assert .Contains (t , output , "Creating isp proxy" )
338357 assert .Contains (t , output , "Successfully created proxy" )
339358}
359+
360+ func TestProxyCreate_ISP_WithoutCountry (t * testing.T ) {
361+ buf := captureOutput (t )
362+
363+ fake := & FakeProxyService {
364+ NewFunc : func (ctx context.Context , body kernel.ProxyNewParams , opts ... option.RequestOption ) (* kernel.ProxyNewResponse , error ) {
365+ // Verify ISP config
366+ ispConfig := body .Config .OfProxyNewsConfigIspProxyConfig
367+ assert .NotNil (t , ispConfig )
368+
369+ return & kernel.ProxyNewResponse {
370+ ID : "isp-new" ,
371+ Name : "ISP Proxy" ,
372+ Type : kernel .ProxyNewResponseTypeIsp ,
373+ }, nil
374+ },
375+ }
376+
377+ p := ProxyCmd {proxies : fake }
378+ err := p .Create (context .Background (), ProxyCreateInput {
379+ Name : "ISP Proxy" ,
380+ Type : "isp" ,
381+ // Country is now optional
382+ })
383+
384+ assert .NoError (t , err )
385+ output := buf .String ()
386+ assert .Contains (t , output , "Creating isp proxy" )
387+ assert .Contains (t , output , "Successfully created proxy" )
388+ }
0 commit comments