(t *testing.T)
| 271 | } |
| 272 | |
| 273 | func TestSourceContainersDir(t *testing.T) { |
| 274 | fs := testTempFileSource(t) |
| 275 | defer os.RemoveAll(string(fs)) |
| 276 | |
| 277 | expected := []*entity.Container{} |
| 278 | |
| 279 | for i := 0; i < 15+rand.Intn(100); i++ { |
| 280 | name := randomString(8) |
| 281 | |
| 282 | kubeContainer := kube.Container{ |
| 283 | Name: name, |
| 284 | Image: randomString(6), |
| 285 | ImagePullPolicy: kube.PullAlways, |
| 286 | } |
| 287 | filename := path.Join(string(fs), name+ContainerExtension) |
| 288 | |
| 289 | container, err := entity.NewContainer(kubeContainer, kube.ObjectMeta{}, filename) |
| 290 | assert.NoError(t, err) |
| 291 | |
| 292 | expected = append(expected, container) |
| 293 | |
| 294 | testWriteYAMLToFile(t, filename, &kubeContainer) |
| 295 | } |
| 296 | |
| 297 | actual, err := fs.Entities(entity.EntityContainer) |
| 298 | assert.NoError(t, err, "should be okay") |
| 299 | assert.Len(t, actual, len(expected), "should have same number of containers as start") |
| 300 | |
| 301 | for _, expectedContainer := range expected { |
| 302 | found := false |
| 303 | for _, actualContainer := range actual { |
| 304 | if expectedContainer.Source() == actualContainer.Source() { |
| 305 | found = testCompareEntity(t, expectedContainer, actualContainer) |
| 306 | if found { |
| 307 | break |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | assert.True(t, found, "should have found container") |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | // TODO: Add test for file |
| 316 |
nothing calls this directly
no test coverage detected