Skip to content

Commit 41c21dc

Browse files
committed
Add test helper to create cluster network config for functional tests
1 parent 9c82d23 commit 41c21dc

File tree

1 file changed

+43
-0
lines changed
  • modules/common/test/helpers

1 file changed

+43
-0
lines changed

modules/common/test/helpers/ocp.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright 2024 Red Hat
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package helpers
15+
16+
import (
17+
"github.com/onsi/gomega"
18+
"sigs.k8s.io/controller-runtime/pkg/client"
19+
20+
ocp_config "github.com/openshift/api/config/v1"
21+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22+
)
23+
24+
// CreateClusterNetworkConfig creates a fake cluster network config CR
25+
func (tc *TestHelper) CreateClusterNetworkConfig() client.Object {
26+
instance := &ocp_config.Network{
27+
ObjectMeta: metav1.ObjectMeta{
28+
Name: "cluster",
29+
Namespace: "",
30+
},
31+
Status: ocp_config.NetworkStatus{
32+
ClusterNetwork: []ocp_config.ClusterNetworkEntry{
33+
{
34+
CIDR: "172.16.0.0/25",
35+
HostPrefix: 24,
36+
},
37+
},
38+
},
39+
}
40+
gomega.Expect(tc.K8sClient.Create(tc.Ctx, instance)).Should(gomega.Succeed())
41+
42+
return instance
43+
}

0 commit comments

Comments
 (0)