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

Function TestSourcePods

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

Source from the content-addressed store, hash-verified

217}
218
219func TestSourcePods(t *testing.T) {
220 fs := testTempFileSource(t)
221 defer os.RemoveAll(string(fs))
222
223 podFile := path.Join(string(fs), "test.pod.yaml")
224
225 terminationPeriod := int64(30)
226 kubePod := &kube.Pod{
227 ObjectMeta: kube.ObjectMeta{
228 Name: "example-pod",
229 Namespace: kube.NamespaceDefault,
230 },
231 TypeMeta: unversioned.TypeMeta{
232 Kind: "Pod",
233 APIVersion: "v1",
234 },
235 Spec: kube.PodSpec{
236 Containers: []kube.Container{
237 {
238 Name: "wiki",
239 Image: "mediawiki",
240 ImagePullPolicy: kube.PullAlways,
241 TerminationMessagePath: kube.TerminationMessagePathDefault,
242 },
243 {
244 Name: "db",
245 Image: "postgres",
246 ImagePullPolicy: kube.PullAlways,
247 TerminationMessagePath: kube.TerminationMessagePathDefault,
248 },
249 },
250 SecurityContext: &kube.PodSecurityContext{},
251 RestartPolicy: kube.RestartPolicyAlways,
252 DNSPolicy: kube.DNSDefault,
253 TerminationGracePeriodSeconds: &terminationPeriod,
254 },
255 }
256
257 testWriteYAMLToFile(t, podFile, kubePod)
258
259 pods, err := fs.Entities(entity.EntityPod)
260 assert.NoError(t, err, "should be okay")
261 assert.Len(t, pods, 1, "should have single pod")
262
263 expectedKubePod := kubePod
264 testClearTypeInfo(expectedKubePod)
265
266 expected, err := entity.NewPod(expectedKubePod, kube.ObjectMeta{}, podFile)
267
268 actual := pods[0]
269
270 testCompareEntity(t, expected, actual)
271}
272
273func TestSourceContainersDir(t *testing.T) {
274 fs := testTempFileSource(t)

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