Atlas › Test

Test_OK_DelayFrom

Exact test identity: go.temporal.io/server/common/quotas/TestMultiReservationSuite/Test_OK_DelayFrom

Package
go.temporal.io/server/common/quotas
Suite / test hierarchy
TestMultiReservationSuite/Test_OK_DelayFrom
Test
Test_OK_DelayFrom
Introduced at
multi_reservation_impl.go ×1 Frontier kind: Joint frontier
Covered ranges
10
Covered lines
33
Covered files
2

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/quotas/reservation_mock.go 18 covered LOC · 4 ranges

Open complete file

30
31 // NewMockReservation creates a new mock instance.
32 > func NewMockReservation(ctrl *gomock.Controller) *MockReservation { reservation_mock.go
33 > mock := &MockReservation{ctrl: ctrl}
34 > mock.recorder = &MockReservationMockRecorder{mock}
35 > return mock
36 > }
37
38 // EXPECT returns an object that allows the caller to indicate expected use.
39 > func (m *MockReservation) EXPECT() *MockReservationMockRecorder { reservation_mock.go
40 > return m.recorder
41 > }
42
43 // Cancel mocks base method.
80
81 // DelayFrom mocks base method.
82 > func (m *MockReservation) DelayFrom(now time.Time) time.Duration { reservation_mock.go
83 > m.ctrl.T.Helper()
84 > ret := m.ctrl.Call(m, "DelayFrom", now)
85 > ret0, _ := ret[0].(time.Duration)
86 > return ret0
87 > }
88
89 // DelayFrom indicates an expected call of DelayFrom.
90 > func (mr *MockReservationMockRecorder) DelayFrom(now any) *gomock.Call { reservation_mock.go
91 > mr.mock.ctrl.T.Helper()
92 > return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DelayFrom", reflect.TypeOf((*MockReservation)(nil).DelayFrom), now)
93 > }
94
95 // OK mocks base method.
go.temporal.io/server/common/quotas/multi_reservation_impl.go 15 covered LOC · 6 ranges

Open complete file

17 ok bool,
18 reservations []Reservation,
19 > ) *MultiReservationImpl { multi_reservation_impl.go
20 > if ok && len(reservations) == 0 {
21 panic("expect at least one reservation")
22 }
23 > return &MultiReservationImpl{ multi_reservation_impl.go
24 > ok: ok,
25 > reservations: reservations,
26 > }
27 }
28
59 // before taking the reserved action. Zero duration means act immediately.
60 // MultiReservation DelayFrom returns the maximum delay of all its sub-reservations.
61 > func (r *MultiReservationImpl) DelayFrom(now time.Time) time.Duration { multi_reservation_impl.go
62 > if !r.ok {
63 return InfDuration
64 }
65
66 > result := r.reservations[0].DelayFrom(now) multi_reservation_impl.go
67 > for _, reservation := range r.reservations {
68 > duration := reservation.DelayFrom(now)
69 > if result < duration {
70 > result = duration multi_reservation_impl.go
71 > }
72 }
73 > return result multi_reservation_impl.go
74 }