@@ -221,38 +221,39 @@ func TestClient_UpdatePrivacySettings(t *testing.T) {
221
221
resp , err := c .UpsertUser (ctx , user )
222
222
require .NoError (t , err , "update users" )
223
223
224
- assert .Equal (t , resp .User .ID , user .ID )
225
- assert .NotNil (t , resp .User .PrivacySettings )
226
- assert .False (t , resp .User .PrivacySettings .TypingIndicators .Enabled )
227
- assert .False (t , resp .User .PrivacySettings .ReadReceipts .Enabled )
224
+ require .Equal (t , resp .User .ID , user .ID )
225
+ require .Nil (t , resp .User .PrivacySettings )
228
226
229
227
user = resp .User
230
- user .PrivacySettings = PrivacySettings {
231
- TypingIndicators : TypingIndicators {
232
- Enabled : true ,
228
+ user .PrivacySettings = & PrivacySettings {
229
+ TypingIndicators : & TypingIndicators {
230
+ Enabled : false ,
233
231
},
234
232
}
235
233
resp , err = c .UpsertUser (ctx , user )
236
234
require .NoError (t , err , "update users" )
237
235
238
- assert .Equal (t , resp .User .ID , user .ID )
239
- assert .NotNil (t , resp .User .PrivacySettings )
240
- assert . True (t , resp .User .PrivacySettings .TypingIndicators .Enabled )
241
- assert . False (t , resp .User .PrivacySettings .ReadReceipts . Enabled )
236
+ require .Equal (t , resp .User .ID , user .ID )
237
+ require .NotNil (t , resp .User .PrivacySettings )
238
+ require . False (t , resp .User .PrivacySettings .TypingIndicators .Enabled )
239
+ require . Nil (t , resp .User .PrivacySettings .ReadReceipts )
242
240
243
241
user = resp .User
244
- user .PrivacySettings = PrivacySettings {
245
- ReadReceipts : ReadReceipts {
242
+ user .PrivacySettings = & PrivacySettings {
243
+ TypingIndicators : & TypingIndicators {
246
244
Enabled : true ,
247
245
},
246
+ ReadReceipts : & ReadReceipts {
247
+ Enabled : false ,
248
+ },
248
249
}
249
250
resp , err = c .UpsertUser (ctx , user )
250
251
require .NoError (t , err , "update users" )
251
252
252
- assert .Equal (t , resp .User .ID , user .ID )
253
- assert .NotNil (t , resp .User .PrivacySettings )
254
- assert . False (t , resp .User .PrivacySettings .TypingIndicators .Enabled )
255
- assert . True (t , resp .User .PrivacySettings .ReadReceipts .Enabled )
253
+ require .Equal (t , resp .User .ID , user .ID )
254
+ require .NotNil (t , resp .User .PrivacySettings )
255
+ require . True (t , resp .User .PrivacySettings .TypingIndicators .Enabled )
256
+ require . False (t , resp .User .PrivacySettings .ReadReceipts .Enabled )
256
257
}
257
258
258
259
func TestClient_PartialUpdateUsers (t * testing.T ) {
@@ -300,10 +301,8 @@ func TestClient_PartialUpdatePrivacySettings(t *testing.T) {
300
301
upsertResponse , err := c .UpsertUser (ctx , user )
301
302
require .NoError (t , err , "update users" )
302
303
303
- assert .Equal (t , upsertResponse .User .ID , user .ID )
304
- assert .NotNil (t , upsertResponse .User .PrivacySettings )
305
- assert .False (t , upsertResponse .User .PrivacySettings .TypingIndicators .Enabled )
306
- assert .False (t , upsertResponse .User .PrivacySettings .ReadReceipts .Enabled )
304
+ require .Equal (t , upsertResponse .User .ID , user .ID )
305
+ require .Nil (t , upsertResponse .User .PrivacySettings )
307
306
308
307
update := PartialUserUpdate {
309
308
ID : user .ID ,
@@ -319,8 +318,23 @@ func TestClient_PartialUpdatePrivacySettings(t *testing.T) {
319
318
partialUpdateResponse , err := c .PartialUpdateUsers (ctx , []PartialUserUpdate {update })
320
319
require .NoError (t , err , "partial update user" )
321
320
322
- assert .True (t , partialUpdateResponse .Users [user .ID ].PrivacySettings .TypingIndicators .Enabled )
323
- assert .False (t , partialUpdateResponse .Users [user .ID ].PrivacySettings .ReadReceipts .Enabled )
321
+ require .True (t , partialUpdateResponse .Users [user .ID ].PrivacySettings .TypingIndicators .Enabled )
322
+ require .Nil (t , partialUpdateResponse .Users [user .ID ].PrivacySettings .ReadReceipts )
323
+
324
+ update = PartialUserUpdate {
325
+ ID : user .ID ,
326
+ Set : map [string ]interface {}{
327
+ "privacy_settings" : map [string ]interface {}{
328
+ "read_receipts" : map [string ]interface {}{
329
+ "enabled" : false ,
330
+ },
331
+ },
332
+ },
333
+ }
334
+ partialUpdateResponse , err = c .PartialUpdateUsers (ctx , []PartialUserUpdate {update })
335
+ require .NoError (t , err , "partial update user" )
336
+ require .True (t , partialUpdateResponse .Users [user .ID ].PrivacySettings .TypingIndicators .Enabled )
337
+ require .False (t , partialUpdateResponse .Users [user .ID ].PrivacySettings .ReadReceipts .Enabled )
324
338
}
325
339
326
340
func ExampleClient_UpsertUser () {
0 commit comments