@@ -10,6 +10,7 @@ import (
10
10
"testing"
11
11
"time"
12
12
13
+ "github.com/hashicorp/jsonapi"
13
14
"github.com/stretchr/testify/assert"
14
15
"github.com/stretchr/testify/require"
15
16
)
@@ -400,14 +401,34 @@ func TestOrganizationsUpdate(t *testing.T) {
400
401
401
402
// Update the default project and verify the change
402
403
updated , err := client .Organizations .Update (ctx , org .Name , OrganizationUpdateOptions {
403
- DefaultProject : proj ,
404
+ DefaultProject : jsonapi. NewNullableRelationshipWithValue [ * Project ]( proj ) ,
404
405
})
405
406
require .NoError (t , err )
406
407
require .Equal (t , proj .ID , updated .DefaultProject .ID )
407
408
408
409
fetched , err := client .Organizations .Read (ctx , org .Name )
409
410
require .NoError (t , err )
410
411
require .Equal (t , proj .ID , fetched .DefaultProject .ID )
412
+
413
+ // Update without setting default project and verify no changes
414
+ updated , err = client .Organizations .Update (ctx , org .Name , OrganizationUpdateOptions {})
415
+ require .NoError (t , err )
416
+ require .Equal (t , proj .ID , updated .DefaultProject .ID )
417
+
418
+ fetched , err = client .Organizations .Read (ctx , org .Name )
419
+ require .NoError (t , err )
420
+ require .Equal (t , proj .ID , fetched .DefaultProject .ID )
421
+
422
+ // Update the setting to an explicit null value and verify it is unset
423
+ deleted , err := client .Organizations .Update (ctx , org .Name , OrganizationUpdateOptions {
424
+ DefaultProject : jsonapi .NewNullNullableRelationship [* Project ](),
425
+ })
426
+ require .NoError (t , err )
427
+ require .Nil (t , deleted .DefaultProject )
428
+
429
+ fetched , err = client .Organizations .Read (ctx , org .Name )
430
+ require .NoError (t , err )
431
+ require .Nil (t , fetched .DefaultProject )
411
432
})
412
433
}
413
434
0 commit comments