utils_test.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2016 Google Inc. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package pubsub
  15. import (
  16. "time"
  17. "golang.org/x/net/context"
  18. )
  19. type modDeadlineCall struct {
  20. subName string
  21. deadline time.Duration
  22. ackIDs []string
  23. }
  24. type acknowledgeCall struct {
  25. subName string
  26. ackIDs []string
  27. }
  28. type testService struct {
  29. service
  30. // The arguments of each call to modifyAckDealine are written to this channel.
  31. modDeadlineCalled chan modDeadlineCall
  32. // The arguments of each call to acknowledge are written to this channel.
  33. acknowledgeCalled chan acknowledgeCall
  34. }
  35. func (s *testService) modifyAckDeadline(ctx context.Context, subName string, deadline time.Duration, ackIDs []string) error {
  36. s.modDeadlineCalled <- modDeadlineCall{
  37. subName: subName,
  38. deadline: deadline,
  39. ackIDs: ackIDs,
  40. }
  41. return nil
  42. }
  43. func (s *testService) acknowledge(ctx context.Context, subName string, ackIDs []string) error {
  44. s.acknowledgeCalled <- acknowledgeCall{
  45. subName: subName,
  46. ackIDs: ackIDs,
  47. }
  48. return nil
  49. }