Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[helpers] MariaDBDatabase and MariaDBAccount create helpers #200

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions api/test/helpers/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,30 @@ func (tc *TestHelper) DeleteDBService(name types.NamespacedName) {
}, tc.Timeout, tc.Interval).Should(gomega.Succeed())
}

// CreateMariaDBDatabase creates a new MariaDBDatabase instance with the specified namespace in the Kubernetes cluster.
func (tc *TestHelper) CreateMariaDBDatabase(namespace string, dbName string, spec mariadbv1.MariaDBDatabaseSpec) types.NamespacedName {
name := types.NamespacedName{
Name: dbName,
Namespace: namespace,
}

db := &mariadbv1.MariaDBDatabase{
TypeMeta: metav1.TypeMeta{
APIVersion: "mariadb.openstack.org/v1beta1",
Kind: "MariaDBDatabase",
},
ObjectMeta: metav1.ObjectMeta{
Name: dbName,
Namespace: namespace,
},
Spec: spec,
}

gomega.Expect(tc.K8sClient.Create(tc.Ctx, db)).Should(gomega.Succeed())

return name
}

// GetMariaDBDatabase waits for and retrieves a MariaDBDatabase resource from the Kubernetes cluster
//
// Example:
Expand Down Expand Up @@ -218,6 +242,30 @@ func (tc *TestHelper) AssertMariaDBDatabaseDoesNotExist(name types.NamespacedNam
}, tc.Timeout, tc.Interval).Should(gomega.Succeed())
}

// CreateMariaDBAccount creates a new MariaDBAccount instance with the specified namespace in the Kubernetes cluster.
func (tc *TestHelper) CreateMariaDBAccount(namespace string, acctName string, spec mariadbv1.MariaDBAccountSpec) types.NamespacedName {
name := types.NamespacedName{
Name: acctName,
Namespace: namespace,
}

db := &mariadbv1.MariaDBAccount{
TypeMeta: metav1.TypeMeta{
APIVersion: "mariadb.openstack.org/v1beta1",
Kind: "MariaDBAccount",
},
ObjectMeta: metav1.ObjectMeta{
Name: acctName,
Namespace: namespace,
},
Spec: spec,
}

gomega.Expect(tc.K8sClient.Create(tc.Ctx, db)).Should(gomega.Succeed())

return name
}

// GetMariaDBAccount waits for and retrieves a MariaDBAccount resource from the Kubernetes cluster
func (tc *TestHelper) GetMariaDBAccount(name types.NamespacedName) *mariadbv1.MariaDBAccount {
instance := &mariadbv1.MariaDBAccount{}
Expand Down
Loading