MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / CreateTestNamespace

Function CreateTestNamespace

tests/utils/namespaces/namespace.go:108–130  ·  view source on GitHub ↗

CreateTestNamespace creates a namespace creates a namespace. Prefer CreateUniqueTestNamespace instead, unless you need a specific namespace name. If so, make sure there is no collision potential. The namespace is automatically cleaned up at the end of the test.

(
	ctx context.Context,
	crudClient client.Client,
	name string,
	opts ...client.CreateOption,
)

Source from the content-addressed store, hash-verified

106// potential.
107// The namespace is automatically cleaned up at the end of the test.
108func CreateTestNamespace(
109 ctx context.Context,
110 crudClient client.Client,
111 name string,
112 opts ...client.CreateOption,
113) error {
114 err := CreateNamespace(ctx, crudClient, name, opts...)
115 if err != nil {
116 return err
117 }
118
119 ginkgo.DeferCleanup(func() error {
120 return cleanupNamespace(
121 ctx,
122 crudClient,
123 name,
124 ginkgo.CurrentSpecReport().LeafNodeText,
125 ginkgo.CurrentSpecReport().Failed(),
126 )
127 })
128
129 return nil
130}
131
132// CreateNamespace creates a namespace.
133func CreateNamespace(

Callers 1

Calls 2

CreateNamespaceFunction · 0.85
cleanupNamespaceFunction · 0.85

Tested by

no test coverage detected