go.etcd.io/etcd@v3.3.27+incompatible/pkg/mock/mockwait/wait_recorder.go (about)

     1  // Copyright 2015 The etcd Authors
     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  
    15  package mockwait
    16  
    17  import (
    18  	"github.com/coreos/etcd/pkg/testutil"
    19  	"github.com/coreos/etcd/pkg/wait"
    20  )
    21  
    22  type WaitRecorder struct {
    23  	wait.Wait
    24  	testutil.Recorder
    25  }
    26  
    27  type waitRecorder struct {
    28  	testutil.RecorderBuffered
    29  }
    30  
    31  func NewRecorder() *WaitRecorder {
    32  	wr := &waitRecorder{}
    33  	return &WaitRecorder{Wait: wr, Recorder: wr}
    34  }
    35  func NewNop() wait.Wait { return NewRecorder() }
    36  
    37  func (w *waitRecorder) Register(id uint64) <-chan interface{} {
    38  	w.Record(testutil.Action{Name: "Register"})
    39  	return nil
    40  }
    41  func (w *waitRecorder) Trigger(id uint64, x interface{}) {
    42  	w.Record(testutil.Action{Name: "Trigger"})
    43  }
    44  
    45  func (w *waitRecorder) IsRegistered(id uint64) bool {
    46  	panic("waitRecorder.IsRegistered() shouldn't be called")
    47  }