(t *testing.T)
| 217 | } |
| 218 | |
| 219 | func 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 | |
| 273 | func TestSourceContainersDir(t *testing.T) { |
| 274 | fs := testTempFileSource(t) |
nothing calls this directly
no test coverage detected