@@ -1968,55 +1968,54 @@ func TestIntegration_TopicRetention(t *testing.T) {
19681968c := integrationTestClient (ctx , t )
19691969defer c .Close ()
19701970
1971- testutil .Retry (t , 5 , 1 * time .Second , func (r * testutil.R ) {
1972- tc := TopicConfig {
1973- RetentionDuration : 50 * time .Minute ,
1974- }
1975- topic , err := createTopicWithRetry (ctx , t , c , topicIDs .New (), & tc )
1976- if err != nil {
1977- r .Errorf ("failed to create topic: %v" , err )
1978- }
1979- defer topic .Delete (ctx )
1980- defer topic .Stop ()
1971+ tc := TopicConfig {
1972+ RetentionDuration : 31 * 24 * time .Hour , // max retention duration
1973+ }
19811974
1982- newDur := 11 * time .Minute
1983- cfg , err := topic .Update (ctx , TopicConfigToUpdate {
1984- RetentionDuration : newDur ,
1985- })
1986- if err != nil {
1987- r .Errorf ("failed to update topic: %v" , err )
1988- }
1989- if got := cfg .RetentionDuration ; got != newDur {
1990- r .Errorf ("cfg.RetentionDuration, got: %v, want: %v" , got , newDur )
1991- }
1975+ topic , err := createTopicWithRetry (ctx , t , c , topicIDs .New (), & tc )
1976+ if err != nil {
1977+ t .Fatalf ("failed to create topic: %v" , err )
1978+ }
1979+ defer topic .Delete (ctx )
1980+ defer topic .Stop ()
19921981
1993- // Create a subscription on the topic and read TopicMessageRetentionDuration.
1994- s , err := createSubWithRetry (ctx , t , c , subIDs .New (), SubscriptionConfig {
1995- Topic : topic ,
1996- })
1997- if err != nil {
1998- r .Errorf ("failed to create subscription: %v" , err )
1999- }
2000- defer s .Delete (ctx )
2001- sCfg , err := s .Config (ctx )
2002- if err != nil {
2003- r .Errorf ("failed to get sub config: %v" , err )
2004- }
2005- if got := sCfg .TopicMessageRetentionDuration ; got != newDur {
2006- r .Errorf ("sCfg.TopicMessageRetentionDuration, got: %v, want: %v" , got , newDur )
2007- }
1982+ newDur := 11 * time .Minute
1983+ cfg , err := topic .Update (ctx , TopicConfigToUpdate {
1984+ RetentionDuration : newDur ,
1985+ })
1986+ if err != nil {
1987+ t .Fatalf ("failed to update topic: %v" , err )
1988+ }
1989+ if got := cfg .RetentionDuration ; got != newDur {
1990+ t .Fatalf ("cfg.RetentionDuration, got: %v, want: %v" , got , newDur )
1991+ }
20081992
2009- // Clear retention duration by setting to a negative value.
2010- cfg , err = topic .Update (ctx , TopicConfigToUpdate {
2011- RetentionDuration : - 1 * time .Minute ,
2012- })
2013- if err != nil {
2014- t .Fatal (err )
2015- }
2016- if got := cfg .RetentionDuration ; got != nil {
2017- t .Fatalf ("expected cleared retention duration, got: %v" , got )
2018- }
1993+ // Create a subscription on the topic and read TopicMessageRetentionDuration.
1994+ s , err := createSubWithRetry (ctx , t , c , subIDs .New (), SubscriptionConfig {
1995+ Topic : topic ,
1996+ })
1997+ if err != nil {
1998+ t .Fatalf ("failed to create subscription: %v" , err )
1999+ }
2000+ defer s .Delete (ctx )
2001+ sCfg , err := s .Config (ctx )
2002+ if err != nil {
2003+ t .Fatalf ("failed to get sub config: %v" , err )
2004+ }
2005+ if got := sCfg .TopicMessageRetentionDuration ; got != newDur {
2006+ t .Fatalf ("sCfg.TopicMessageRetentionDuration, got: %v, want: %v" , got , newDur )
2007+ }
2008+
2009+ // Clear retention duration by setting to a negative value.
2010+ cfg , err = topic .Update (ctx , TopicConfigToUpdate {
2011+ RetentionDuration : - 1 * time .Minute ,
20192012})
2013+ if err != nil {
2014+ t .Fatal (err )
2015+ }
2016+ if got := cfg .RetentionDuration ; got != nil {
2017+ t .Fatalf ("expected cleared retention duration, got: %v" , got )
2018+ }
20202019}
20212020
20222021func TestIntegration_ExactlyOnceDelivery_PublishReceive (t * testing.T ) {
0 commit comments