@@ -43,3 +43,124 @@ func TestGetMachineSets(t *testing.T) {
43
43
g .Expect (machine .Namespace ).To (gomega .Equal ("openshift-machine-api" ))
44
44
45
45
}
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
+ */
0 commit comments