@@ -420,6 +420,41 @@ func TestMarshalOmitEmpty(t *testing.T) {
420
420
}
421
421
}
422
422
423
+ type customNullMarshaler struct {}
424
+
425
+ func (m customNullMarshaler ) MarshalDynamoDBStreamsAttributeValue () (types.AttributeValue , error ) {
426
+ return & types.AttributeValueMemberNULL {Value : true }, nil
427
+ }
428
+
429
+ type testOmitEmptyCustom struct {
430
+ CustomNullOmit customNullMarshaler `dynamodbav:",omitempty"`
431
+ CustomNullOmitTagKey customNullMarshaler `tagkey:",omitempty"`
432
+ CustomNullPresent customNullMarshaler
433
+ EmptySetOmit []string `dynamodbav:",omitempty"`
434
+ }
435
+
436
+ func TestMarshalOmitEmptyCustom (t * testing.T ) {
437
+ expect := & types.AttributeValueMemberM {
438
+ Value : map [string ]types.AttributeValue {
439
+ "CustomNullPresent" : & types.AttributeValueMemberNULL {Value : true },
440
+ },
441
+ }
442
+
443
+ m := testOmitEmptyCustom {}
444
+
445
+ actual , err := MarshalWithOptions (m , func (eo * EncoderOptions ) {
446
+ eo .TagKey = "tagkey"
447
+ eo .OmitNullAttributeValues = true
448
+ eo .NullEmptySets = true
449
+ })
450
+ if err != nil {
451
+ t .Errorf ("expect nil, got %v" , err )
452
+ }
453
+ if e , a := expect , actual ; ! reflect .DeepEqual (e , a ) {
454
+ t .Errorf ("expect %v, got %v" , e , a )
455
+ }
456
+ }
457
+
423
458
func TestEncodeEmbeddedPointerStruct (t * testing.T ) {
424
459
type B struct {
425
460
Bint int
0 commit comments