Skip to content

Commit 67ad75f

Browse files
committed
add method to simply create fake Clusters for testing purposes
1 parent 5386351 commit 67ad75f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/clusters/cluster.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ func New(id string) *Cluster {
3636
return c
3737
}
3838

39+
// NewTestClusterFromClient creates a Cluster from a given client.
40+
// Note that this method is meant for testing purposes only and it does not result in a fully functional Cluster.
41+
// Calling anything except Client() on the resulting Cluster is undefined and might lead to panics or unexpected behavior.
42+
func NewTestClusterFromClient(id string, cli client.Client) *Cluster {
43+
c := &Cluster{}
44+
c.InitializeID(id)
45+
c.client = cli
46+
return c
47+
}
48+
3949
// WithConfigPath sets the config path for the cluster.
4050
// Returns the cluster for chaining.
4151
func (c *Cluster) WithConfigPath(cfgPath string) *Cluster {

0 commit comments

Comments
 (0)