(t *testing.T)
| 257 | } |
| 258 | |
| 259 | func TestRCAttachPod(t *testing.T) { |
| 260 | kubeContainer := kube.Container{ |
| 261 | Name: "redis", |
| 262 | Image: "redis", |
| 263 | ImagePullPolicy: kube.PullAlways, |
| 264 | } |
| 265 | selector := map[string]string{ |
| 266 | "app": "db", |
| 267 | } |
| 268 | |
| 269 | // create ReplicationController |
| 270 | rcObjects := testRandomObjects(10) |
| 271 | rc := testNewRC(t, "container-test", selector, rcObjects) |
| 272 | |
| 273 | // create kube.Pod |
| 274 | // create Pod from created pod |
| 275 | kubePod := &kube.Pod{ |
| 276 | ObjectMeta: kube.ObjectMeta{Name: "attached"}, |
| 277 | Spec: kube.PodSpec{ |
| 278 | Containers: []kube.Container{ |
| 279 | kubeContainer, |
| 280 | }, |
| 281 | RestartPolicy: kube.RestartPolicyAlways, |
| 282 | DNSPolicy: kube.DNSDefault, |
| 283 | }, |
| 284 | } |
| 285 | podObjects := testRandomObjects(10) |
| 286 | pod, err := NewPod(kubePod, kube.ObjectMeta{}, "", podObjects...) |
| 287 | assert.NoError(t, err, "should be valid pod") |
| 288 | |
| 289 | // Attach pod to RC |
| 290 | // Should assume defaults up tree creating necessary components |
| 291 | err = rc.Attach(pod) |
| 292 | assert.NoError(t, err, "pod should be able to attach to ") |
| 293 | children := rc.children() |
| 294 | assert.Contains(t, children, pod, "should have image as child") |
| 295 | |
| 296 | // Compare internal elements |
| 297 | assert.NotNil(t, rc.pod, "should of created pod") |
| 298 | assert.Len(t, rc.pod.containers, 1) |
| 299 | |
| 300 | // Create struct representation for expected |
| 301 | // Insert into Deployment |
| 302 | // Create Deployment from RC |
| 303 | rcMeta := rc.rc.ObjectMeta |
| 304 | rcMeta.Namespace = kube.NamespaceDefault |
| 305 | |
| 306 | podMeta := pod.pod.ObjectMeta |
| 307 | podMeta.Labels = selector |
| 308 | expectedRC := &kube.ReplicationController{ |
| 309 | ObjectMeta: rcMeta, |
| 310 | Spec: kube.ReplicationControllerSpec{ |
| 311 | Selector: selector, |
| 312 | Template: &kube.PodTemplateSpec{ |
| 313 | ObjectMeta: kube.ObjectMeta{ |
| 314 | Namespace: kube.NamespaceDefault, |
| 315 | Labels: selector, |
| 316 | }, |
nothing calls this directly
no test coverage detected