/
fake.go
34 lines (28 loc) · 1003 Bytes
/
fake.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package cluster
import (
crv1 "github.com/grtl/mysql-operator/pkg/apis/cr/v1"
)
// FakeClusterOperator may be used in tests as a cluster operator.
// It implements all operator functions as simply returning an fail
// set via SetError.
type FakeClusterOperator struct {
err error
}
// NewFakeOperator returns new operator that does nothing.
func NewFakeOperator() *FakeClusterOperator {
return new(FakeClusterOperator)
}
// SetError can be used to simulate operator failures.
func (c *FakeClusterOperator) SetError(err error) {
c.err = err
}
// AddCluster simulates adding a cluster. Returns fail set via SetError.
func (c *FakeClusterOperator) AddCluster(cluster *crv1.MySQLCluster) error {
// Just pretend we're adding a cluster. Return err.
return c.err
}
// UpdateCluster simulates updating a cluster. Returns fail set via SetError.
func (c *FakeClusterOperator) UpdateCluster(newCluster *crv1.MySQLCluster) error {
// Just pretend we're updating a cluster. Do nothing.
return c.err
}