MCPcopy
hub / github.com/redspread/spread / TestSourceRCs

Function TestSourceRCs

pkg/input/dir/source_test.go:154–217  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

152}
153
154func TestSourceRCs(t *testing.T) {
155 fs := testTempFileSource(t)
156 defer os.RemoveAll(string(fs))
157
158 rcFile := path.Join(string(fs), "test.rc.json")
159
160 selector := map[string]string{"app": "example"}
161
162 terminationPeriod := int64(30)
163 kubeRC := &kube.ReplicationController{
164 ObjectMeta: kube.ObjectMeta{
165 Name: "example-rc",
166 Namespace: kube.NamespaceDefault,
167 },
168 TypeMeta: unversioned.TypeMeta{
169 Kind: "ReplicationController",
170 APIVersion: "v1",
171 },
172 Spec: kube.ReplicationControllerSpec{
173 Selector: selector,
174 Replicas: 2,
175 Template: &kube.PodTemplateSpec{
176 ObjectMeta: kube.ObjectMeta{
177 Labels: selector,
178 },
179 Spec: kube.PodSpec{
180 Containers: []kube.Container{
181 {
182 Name: "example",
183 Image: "hello-world",
184 ImagePullPolicy: kube.PullAlways,
185 TerminationMessagePath: kube.TerminationMessagePathDefault,
186 },
187 {
188 Name: "cache",
189 Image: "redis",
190 ImagePullPolicy: kube.PullAlways,
191 TerminationMessagePath: kube.TerminationMessagePathDefault,
192 },
193 },
194 SecurityContext: &kube.PodSecurityContext{},
195 RestartPolicy: kube.RestartPolicyAlways,
196 DNSPolicy: kube.DNSDefault,
197 TerminationGracePeriodSeconds: &terminationPeriod,
198 },
199 },
200 },
201 }
202
203 testWriteYAMLToFile(t, rcFile, kubeRC)
204
205 rcs, err := fs.Entities(entity.EntityReplicationController)
206 assert.NoError(t, err, "should be okay")
207 assert.Len(t, rcs, 1, "should have single rc")
208
209 expectedKubeRC := kubeRC
210 testClearTypeInfo(expectedKubeRC)
211 expectedKubeRC.Labels = selector

Callers

nothing calls this directly

Calls 6

testTempFileSourceFunction · 0.85
testWriteYAMLToFileFunction · 0.85
testClearTypeInfoFunction · 0.85
testCompareEntityFunction · 0.85
EntitiesMethod · 0.80
LenMethod · 0.45

Tested by

no test coverage detected