Skip to content

Commit 4b870a8

Browse files
committed
Made PR Checks issues clearance
1 parent 320ebaa commit 4b870a8

File tree

3 files changed

+161
-6
lines changed

3 files changed

+161
-6
lines changed

support/environment_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ func TestGetPyTorchImage(t *testing.T) {
6363
}
6464
}
6565

66-
func TestGetOsdClusterID(t *testing.T) {
67-
os.Setenv(OsdClusterID, "my-cluster-id")
68-
clusterId, ok := GetOsdClusterId()
66+
func TestGetClusterID(t *testing.T) {
67+
os.Setenv(ClusterID, "my-cluster-id")
68+
clusterId, ok := GetClusterId()
6969
if !ok {
70-
gomega.Expect(ok).To(gomega.BeTrue(), "Expected GetOsdClusterId() to return true, but got false.")
70+
gomega.Expect(ok).To(gomega.BeTrue(), "Expected GetClusterId() to return true, but got false.")
7171
}
7272
if clusterId != "my-cluster-id" {
73-
gomega.Expect(clusterId).To(gomega.Equal("my-cluster-id"), "Expected GetOsdClusterId() to return 'my-cluster-id', but got '%s'.", clusterId)
73+
gomega.Expect(clusterId).To(gomega.Equal("my-cluster-id"), "Expected GetClusterId() to return 'my-cluster-id', but got '%s'.", clusterId)
7474
}
7575

7676
}
@@ -118,7 +118,6 @@ func TestGetClusterType(t *testing.T) {
118118
envVarValue: "KIND",
119119
expected: KindCluster,
120120
},
121-
122121
}
123122
ttt := With(t)
124123
for _, tt := range tests {

support/machine_test.go

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,124 @@ func TestGetMachineSets(t *testing.T) {
4343
g.Expect(machine.Namespace).To(gomega.Equal("openshift-machine-api"))
4444

4545
}
46+
47+
/*
48+
import (
49+
50+
"testing"
51+
52+
"github.com/onsi/gomega"
53+
machinev1beta1 "github.com/openshift/api/machine/v1beta1"
54+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
55+
"k8s.io/apimachinery/pkg/runtime"
56+
"k8s.io/client-go/kubernetes/fake"
57+
58+
"sigs.k8s.io/controller-runtime/pkg/client"
59+
60+
"k8s.io/client-go/kubernetes"
61+
62+
)
63+
64+
func TestGetMachines(t *testing.T) {
65+
g := gomega.NewWithT(t)
66+
67+
// Create a fake client with test data
68+
scheme := runtime.NewScheme()
69+
_ = machinev1beta1.AddToScheme(scheme)
70+
testmachines := []client.Object{
71+
&machinev1beta1.Machine{
72+
ObjectMeta: metav1.ObjectMeta{
73+
Name: "machine-1",
74+
Namespace: "default",
75+
},
76+
// ...
77+
},
78+
&machinev1beta1.Machine{
79+
ObjectMeta: metav1.ObjectMeta{
80+
Name: "machine-2",
81+
Namespace: "default",
82+
},
83+
// ...
84+
},
85+
}
86+
fakeClient := fake.NewSimpleClientset(testmachines...)
87+
88+
// Define the machine set name to use in the test
89+
machineSetName := "my-machine-set"
90+
91+
// Create a fake test object with the fake client
92+
test := fakeTest{t, fakeClient}
93+
94+
// Call the GetMachines function and assert the result
95+
result := GetMachines(test, machineSetName)
96+
g.Expect(result).To(gomega.HaveLen(2))
97+
g.Expect(result[0].Name).To(gomega.Equal("machine-1"))
98+
g.Expect(result[1].Name).To(gomega.Equal("machine-2"))
99+
}
100+
101+
// Define a fake test object that implements the Test interface
102+
type fakeTest struct {
103+
*testing.T
104+
client kubernetes.Interface
105+
}
106+
107+
// Implement the Test interface for the fakeTest object
108+
func (f fakeTest) Client() kubernetes.Interface {
109+
return f.client
110+
}
111+
*/
112+
/*
113+
114+
func TestGetMachines(t *testing.T) {
115+
g := gomega.NewWithT(t)
116+
117+
scheme := runtime.NewScheme()
118+
_ = machinev1beta1.AddToScheme(scheme)
119+
// Create a fake client and add some test data
120+
testmachines := []client.Object{
121+
&machinev1beta1.Machine{
122+
ObjectMeta: metav1.ObjectMeta{
123+
Name: "machine-1",
124+
Namespace: "default",
125+
},
126+
// ...
127+
},
128+
&machinev1beta1.Machine{
129+
ObjectMeta: metav1.ObjectMeta{
130+
Name: "machine-2",
131+
Namespace: "default",
132+
},
133+
// ...
134+
},
135+
}
136+
_ = NewFakeKubeClientWithMachines(scheme, testmachines...)
137+
// Define the machine set name to use in the test
138+
machineSetName := "my-machine-set"
139+
140+
test := With(t).(*T)
141+
142+
143+
144+
// Call the GetMachines function and assert the result
145+
result := GetMachines(test, machineSetName)
146+
g.Expect(result).To(gomega.HaveLen(3))
147+
g.Expect(result[0].Name).To(gomega.Equal("machine-1"))
148+
g.Expect(result[1].Name).To(gomega.Equal("machine-2"))
149+
}
150+
151+
*/
152+
/*
153+
import (
154+
"testing"
155+
"github.com/stretchr/testify/assert"
156+
)
157+
func TestGetMachines(t *testing.T) {
158+
t.Run("GetMachines returns machines for a given machine set", func(t *testing.T) {
159+
machineSetName := "test-machine-set"
160+
test := With(t).(*T)
161+
machines := GetMachines(test, machineSetName)
162+
assert.Len(t, machines, 1)
163+
assert.Equal(t, machines[0].Name, "test-machine")
164+
})
165+
}
166+
*/

support/ocm_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,36 @@
11
package support
2+
/*
3+
import (
4+
"testing"
5+
6+
"github.com/onsi/gomega"
7+
8+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9+
"k8s.io/client-go/kubernetes/fake"
10+
11+
ocmsdk "github.com/openshift-online/ocm-sdk-go"
12+
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
13+
)
14+
15+
func TestGetMachinePools(t *testing.T) {
16+
// Create a fake OpenShift client for testing
17+
fakeClient := fake.NewSimpleClientset(&machinePool{
18+
MachinePool: &cmv1.MachinePool{
19+
ObjectMeta: metav1.ObjectMeta{
20+
Name: "test-machinepool",
21+
Namespace: "test-namespace",
22+
},
23+
},
24+
})
25+
26+
test := With(t).(*T)
27+
test.client = &testClient{
28+
core: fakeClient,
29+
}
30+
31+
// Call the GetMachinePools function with the fake client and connection
32+
machinePools := GetMachinePools(test, &ocmsdk.Connection{})
33+
34+
test.Expect(machinePools).Should(gomega.HaveLen(1), "Expected 1 machine pool, but got %d", len(machinePools))
35+
}
36+
*/

0 commit comments

Comments
 (0)