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

Function TestRCAttachContainer

pkg/entity/replicationcontroller_test.go:186–257  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

184}
185
186func TestRCAttachContainer(t *testing.T) {
187 containerName := "attached"
188 imageName := "embedded-image"
189 selector := map[string]string{
190 "app": "db",
191 }
192
193 // create ReplicationController
194 rcObjects := testRandomObjects(10)
195 rc := testNewRC(t, "container-test", selector, rcObjects)
196
197 // create kube.Container
198 // create Container from created container
199 containerObjects := testRandomObjects(20)
200 kubeContainer := testNewKubeContainer(containerName, imageName)
201 container, err := NewContainer(kubeContainer, kube.ObjectMeta{}, "", containerObjects...)
202 assert.NoError(t, err, "should be valid container")
203
204 // Attach container to RC
205 // Should assume defaults up tree creating necessary components
206 err = rc.Attach(container)
207 assert.NoError(t, err, "container should be able to attach to rc")
208
209 // Compare internal elements
210 assert.NotNil(t, rc.pod, "should of created pod")
211 // assert.Len(t, rc.pod.containers, 1)
212
213 // Create struct representation for expected
214 // Insert into Deployment
215 // Create Deployment from RC
216 rcMeta := rc.rc.ObjectMeta
217 rcMeta.Namespace = kube.NamespaceDefault
218 expectedRC := &kube.ReplicationController{
219 ObjectMeta: rcMeta,
220 Spec: kube.ReplicationControllerSpec{
221 Selector: selector,
222 Template: &kube.PodTemplateSpec{
223 ObjectMeta: kube.ObjectMeta{
224 Labels: selector,
225 Namespace: kube.NamespaceDefault,
226 },
227 Spec: kube.PodSpec{
228 Containers: []kube.Container{
229 kubeContainer,
230 },
231 RestartPolicy: kube.RestartPolicyAlways,
232 DNSPolicy: kube.DNSDefault,
233 },
234 },
235 },
236 }
237
238 // Insert into Deployment
239 expected := new(deploy.Deployment)
240 err = expected.Add(expectedRC)
241 assert.NoError(t, err, "should be valid RC")
242
243 // add objects to deployment

Callers

nothing calls this directly

Calls 11

testNewRCFunction · 0.85
testNewKubeContainerFunction · 0.85
NewContainerFunction · 0.85
testDeploymentEqualFunction · 0.85
AddDeploymentMethod · 0.80
testRandomObjectsFunction · 0.70
AttachMethod · 0.65
DeploymentMethod · 0.65
ImagesMethod · 0.65
AddMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected