@@ -62,10 +62,11 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
6262 ResponseHeaders : []string {"FOO" },
6363 },
6464 },
65- Encryption : & BucketEncryption {DefaultKMSKeyName : "key" },
66- Logging : & BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
67- Website : & BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
68- Autoclass : & Autoclass {Enabled : true , TerminalStorageClass : "NEARLINE" },
65+ Encryption : & BucketEncryption {DefaultKMSKeyName : "key" },
66+ Logging : & BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
67+ Website : & BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
68+ Autoclass : & Autoclass {Enabled : true , TerminalStorageClass : "NEARLINE" },
69+ SoftDeletePolicy : & SoftDeletePolicy {RetentionDuration : time .Hour },
6970 Lifecycle : Lifecycle {
7071 Rules : []LifecycleRule {{
7172 Action : LifecycleAction {
@@ -166,10 +167,11 @@ func TestBucketAttrsToRawBucket(t *testing.T) {
166167 ResponseHeader : []string {"FOO" },
167168 },
168169 },
169- Encryption : & raw.BucketEncryption {DefaultKmsKeyName : "key" },
170- Logging : & raw.BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
171- Website : & raw.BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
172- Autoclass : & raw.BucketAutoclass {Enabled : true , TerminalStorageClass : "NEARLINE" },
170+ Encryption : & raw.BucketEncryption {DefaultKmsKeyName : "key" },
171+ Logging : & raw.BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
172+ Website : & raw.BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
173+ Autoclass : & raw.BucketAutoclass {Enabled : true , TerminalStorageClass : "NEARLINE" },
174+ SoftDeletePolicy : & raw.BucketSoftDeletePolicy {RetentionDurationSeconds : 60 * 60 },
173175 Lifecycle : & raw.BucketLifecycle {
174176 Rule : []* raw.BucketLifecycleRule {{
175177 Action : & raw.BucketLifecycleRuleAction {
@@ -395,10 +397,11 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) {
395397 },
396398 },
397399 },
398- Logging : & BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
399- Website : & BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
400- StorageClass : "NEARLINE" ,
401- Autoclass : & Autoclass {Enabled : true , TerminalStorageClass : "ARCHIVE" },
400+ Logging : & BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
401+ Website : & BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
402+ StorageClass : "NEARLINE" ,
403+ Autoclass : & Autoclass {Enabled : true , TerminalStorageClass : "ARCHIVE" },
404+ SoftDeletePolicy : & SoftDeletePolicy {RetentionDuration : time .Hour },
402405 }
403406 au .SetLabel ("a" , "foo" )
404407 au .DeleteLabel ("b" )
@@ -439,11 +442,12 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) {
439442 },
440443 },
441444 },
442- Logging : & raw.BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
443- Website : & raw.BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
444- StorageClass : "NEARLINE" ,
445- Autoclass : & raw.BucketAutoclass {Enabled : true , TerminalStorageClass : "ARCHIVE" , ForceSendFields : []string {"Enabled" }},
446- ForceSendFields : []string {"DefaultEventBasedHold" , "Lifecycle" , "Autoclass" },
445+ Logging : & raw.BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
446+ Website : & raw.BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
447+ StorageClass : "NEARLINE" ,
448+ Autoclass : & raw.BucketAutoclass {Enabled : true , TerminalStorageClass : "ARCHIVE" , ForceSendFields : []string {"Enabled" }},
449+ SoftDeletePolicy : & raw.BucketSoftDeletePolicy {RetentionDurationSeconds : 3600 },
450+ ForceSendFields : []string {"DefaultEventBasedHold" , "Lifecycle" , "Autoclass" },
447451 }
448452 if msg := testutil .Diff (got , want ); msg != "" {
449453 t .Error (msg )
@@ -463,14 +467,15 @@ func TestBucketAttrsToUpdateToRawBucket(t *testing.T) {
463467
464468 // Test nulls.
465469 au3 := & BucketAttrsToUpdate {
466- RetentionPolicy : & RetentionPolicy {},
467- Encryption : & BucketEncryption {},
468- Logging : & BucketLogging {},
469- Website : & BucketWebsite {},
470+ RetentionPolicy : & RetentionPolicy {},
471+ Encryption : & BucketEncryption {},
472+ Logging : & BucketLogging {},
473+ Website : & BucketWebsite {},
474+ SoftDeletePolicy : & SoftDeletePolicy {},
470475 }
471476 got = au3 .toRawBucket ()
472477 want = & raw.Bucket {
473- NullFields : []string {"RetentionPolicy" , "Encryption" , "Logging" , "Website" },
478+ NullFields : []string {"RetentionPolicy" , "Encryption" , "Logging" , "Website" , "SoftDeletePolicy" },
474479 }
475480 if msg := testutil .Diff (got , want ); msg != "" {
476481 t .Error (msg )
@@ -656,6 +661,10 @@ func TestNewBucket(t *testing.T) {
656661 TerminalStorageClass : "NEARLINE" ,
657662 TerminalStorageClassUpdateTime : "2017-10-23T04:05:06Z" ,
658663 },
664+ SoftDeletePolicy : & raw.BucketSoftDeletePolicy {
665+ EffectiveTime : "2017-10-23T04:05:06Z" ,
666+ RetentionDurationSeconds : 3600 ,
667+ },
659668 }
660669 want := & BucketAttrs {
661670 Name : "name" ,
@@ -713,6 +722,10 @@ func TestNewBucket(t *testing.T) {
713722 TerminalStorageClass : "NEARLINE" ,
714723 TerminalStorageClassUpdateTime : time .Date (2017 , 10 , 23 , 4 , 5 , 6 , 0 , time .UTC ),
715724 },
725+ SoftDeletePolicy : & SoftDeletePolicy {
726+ EffectiveTime : time .Date (2017 , 10 , 23 , 4 , 5 , 6 , 0 , time .UTC ),
727+ RetentionDuration : time .Hour ,
728+ },
716729 }
717730 got , err := newBucket (rb )
718731 if err != nil {
@@ -768,6 +781,10 @@ func TestNewBucketFromProto(t *testing.T) {
768781 TerminalStorageClass : & autoclassTSC ,
769782 TerminalStorageClassUpdateTime : toProtoTimestamp (time .Date (2020 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC )),
770783 },
784+ SoftDeletePolicy : & storagepb.Bucket_SoftDeletePolicy {
785+ RetentionDuration : durationpb .New (3 * time .Hour ),
786+ EffectiveTime : toProtoTimestamp (time .Date (2020 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC )),
787+ },
771788 Lifecycle : & storagepb.Bucket_Lifecycle {
772789 Rule : []* storagepb.Bucket_Lifecycle_Rule {
773790 {
@@ -809,6 +826,10 @@ func TestNewBucketFromProto(t *testing.T) {
809826 Logging : & BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
810827 Website : & BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
811828 Autoclass : & Autoclass {Enabled : true , ToggleTime : time .Date (2020 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ), TerminalStorageClass : "NEARLINE" , TerminalStorageClassUpdateTime : time .Date (2020 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC )},
829+ SoftDeletePolicy : & SoftDeletePolicy {
830+ EffectiveTime : time .Date (2020 , 1 , 1 , 0 , 0 , 0 , 0 , time .UTC ),
831+ RetentionDuration : time .Hour * 3 ,
832+ },
812833 Lifecycle : Lifecycle {
813834 Rules : []LifecycleRule {{
814835 Action : LifecycleAction {
@@ -853,10 +874,11 @@ func TestBucketAttrsToProtoBucket(t *testing.T) {
853874 ResponseHeaders : []string {"FOO" },
854875 },
855876 },
856- Encryption : & BucketEncryption {DefaultKMSKeyName : "key" },
857- Logging : & BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
858- Website : & BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
859- Autoclass : & Autoclass {Enabled : true , TerminalStorageClass : "ARCHIVE" },
877+ Encryption : & BucketEncryption {DefaultKMSKeyName : "key" },
878+ Logging : & BucketLogging {LogBucket : "lb" , LogObjectPrefix : "p" },
879+ Website : & BucketWebsite {MainPageSuffix : "mps" , NotFoundPage : "404" },
880+ Autoclass : & Autoclass {Enabled : true , TerminalStorageClass : "ARCHIVE" },
881+ SoftDeletePolicy : & SoftDeletePolicy {RetentionDuration : time .Hour * 2 },
860882 Lifecycle : Lifecycle {
861883 Rules : []LifecycleRule {{
862884 Action : LifecycleAction {
@@ -903,10 +925,11 @@ func TestBucketAttrsToProtoBucket(t *testing.T) {
903925 ResponseHeader : []string {"FOO" },
904926 },
905927 },
906- Encryption : & storagepb.Bucket_Encryption {DefaultKmsKey : "key" },
907- Logging : & storagepb.Bucket_Logging {LogBucket : "projects/_/buckets/lb" , LogObjectPrefix : "p" },
908- Website : & storagepb.Bucket_Website {MainPageSuffix : "mps" , NotFoundPage : "404" },
909- Autoclass : & storagepb.Bucket_Autoclass {Enabled : true , TerminalStorageClass : & autoclassTSC },
928+ Encryption : & storagepb.Bucket_Encryption {DefaultKmsKey : "key" },
929+ Logging : & storagepb.Bucket_Logging {LogBucket : "projects/_/buckets/lb" , LogObjectPrefix : "p" },
930+ Website : & storagepb.Bucket_Website {MainPageSuffix : "mps" , NotFoundPage : "404" },
931+ Autoclass : & storagepb.Bucket_Autoclass {Enabled : true , TerminalStorageClass : & autoclassTSC },
932+ SoftDeletePolicy : & storagepb.Bucket_SoftDeletePolicy {RetentionDuration : durationpb .New (2 * time .Hour )},
910933 Lifecycle : & storagepb.Bucket_Lifecycle {
911934 Rule : []* storagepb.Bucket_Lifecycle_Rule {
912935 {
0 commit comments