Support cluster injection in HTTP unit tests
@@ -818,6 +818,8 @@ func (m *MockStore) Backup(leader bool, f store.BackupFormat, w io.Writer) error
type mockClusterService struct {
apiAddr string
+ executeFn func(addr string, er *command.ExecuteRequest, t time.Duration) ([]*command.ExecuteResult, error)
+ queryFn func(addr string, qr *command.QueryRequest, t time.Duration) ([]*command.QueryRows, error)
}
func (m *mockClusterService) GetNodeAPIAddr(a string) (string, error) {
@@ -825,10 +827,16 @@ func (m *mockClusterService) GetNodeAPIAddr(a string) (string, error) {
}
func (m *mockClusterService) Execute(addr string, er *command.ExecuteRequest, t time.Duration) ([]*command.ExecuteResult, error) {
+ if m.executeFn != nil {
+ return m.executeFn(addr, er, t)
+ }
return nil, nil
}
func (m *mockClusterService) Query(addr string, qr *command.QueryRequest, t time.Duration) ([]*command.QueryRows, error) {
+ if m.queryFn != nil {
+ return m.queryFn(addr, qr, t)
+ }
return nil, nil
}
