@@ -25,12 +25,13 @@ import (
2525 "time"
2626
2727 "cloud.google.com/go/internal/testutil"
28- "github.com/golang/protobuf/ptypes"
2928 pb "google.golang.org/genproto/googleapis/pubsub/v1"
3029 "google.golang.org/genproto/protobuf/field_mask"
3130 "google.golang.org/grpc"
3231 "google.golang.org/grpc/codes"
3332 "google.golang.org/grpc/status"
33+ "google.golang.org/protobuf/types/known/durationpb"
34+ "google.golang.org/protobuf/types/known/timestamppb"
3435)
3536
3637func TestTopics (t * testing.T ) {
@@ -185,7 +186,7 @@ func TestSubscriptionErrors(t *testing.T) {
185186 checkCode (err , codes .NotFound )
186187 _ , err = sclient .Seek (ctx , & pb.SeekRequest {})
187188 checkCode (err , codes .InvalidArgument )
188- srt := & pb.SeekRequest_Time {Time : ptypes . TimestampNow ()}
189+ srt := & pb.SeekRequest_Time {Time : timestamppb . Now ()}
189190 _ , err = sclient .Seek (ctx , & pb.SeekRequest {Target : srt })
190191 checkCode (err , codes .InvalidArgument )
191192 _ , err = sclient .Seek (ctx , & pb.SeekRequest {Target : srt , Subscription : "s" })
@@ -278,10 +279,7 @@ func publish(t *testing.T, pclient pb.PublisherClient, topic *pb.Topic, messages
278279 if err != nil {
279280 t .Fatal (err )
280281 }
281- tsPubTime , err := ptypes .TimestampProto (pubTime )
282- if err != nil {
283- t .Fatal (err )
284- }
282+ tsPubTime := timestamppb .New (pubTime )
285283 want := map [string ]* pb.PubsubMessage {}
286284 for i , id := range res .MessageIds {
287285 want [id ] = & pb.PubsubMessage {
@@ -639,7 +637,7 @@ func TestSeek(t *testing.T) {
639637 Topic : top .Name ,
640638 AckDeadlineSeconds : 10 ,
641639 })
642- ts := ptypes . TimestampNow ()
640+ ts := timestamppb . Now ()
643641 _ , err := sclient .Seek (context .Background (), & pb.SeekRequest {
644642 Subscription : sub .Name ,
645643 Target : & pb.SeekRequest_Time {Time : ts },
@@ -700,7 +698,7 @@ func TestTimeNowFunc(t *testing.T) {
700698
701699 m := s .Message (id )
702700 if m == nil {
703- t .Error ("got nil, want a message" )
701+ t .Fatalf ("got nil, want a message" )
704702 }
705703 if got , want := m .PublishTime , timeFunc (); got != want {
706704 t .Fatalf ("got %v, want %v" , got , want )
@@ -797,8 +795,8 @@ func TestUpdateRetryPolicy(t *testing.T) {
797795 Name : "projects/P/subscriptions/S" ,
798796 Topic : top .Name ,
799797 RetryPolicy : & pb.RetryPolicy {
800- MinimumBackoff : ptypes . DurationProto (10 * time .Second ),
801- MaximumBackoff : ptypes . DurationProto (60 * time .Second ),
798+ MinimumBackoff : durationpb . New (10 * time .Second ),
799+ MaximumBackoff : durationpb . New (60 * time .Second ),
802800 },
803801 })
804802
@@ -807,8 +805,8 @@ func TestUpdateRetryPolicy(t *testing.T) {
807805 Name : sub .Name ,
808806 Topic : top .Name ,
809807 RetryPolicy : & pb.RetryPolicy {
810- MinimumBackoff : ptypes . DurationProto (20 * time .Second ),
811- MaximumBackoff : ptypes . DurationProto (100 * time .Second ),
808+ MinimumBackoff : durationpb . New (20 * time .Second ),
809+ MaximumBackoff : durationpb . New (100 * time .Second ),
812810 },
813811 }
814812
@@ -1007,7 +1005,7 @@ func TestErrorInjection(t *testing.T) {
10071005 },
10081006 {
10091007 funcName : "Seek" ,
1010- param : & pb.SeekRequest {Target : & pb.SeekRequest_Time {Time : ptypes . TimestampNow ()}},
1008+ param : & pb.SeekRequest {Target : & pb.SeekRequest_Time {Time : timestamppb . Now ()}},
10111009 },
10121010 }
10131011
0 commit comments