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

Function TestRCAttachImage

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

Source from the content-addressed store, hash-verified

108}
109
110func TestRCAttachImage(t *testing.T) {
111 imageName := "rc-attach-image"
112 rcName := "image-test"
113 selector := map[string]string{
114 "app": "cache",
115 }
116
117 // create ReplicationController
118 rcObjects := testRandomObjects(10)
119 rc := testNewRC(t, rcName, selector, rcObjects)
120
121 // create Image
122 imageObjects := testRandomObjects(10)
123 imageEntity := testNewImage(t, imageName, kube.ObjectMeta{}, "", imageObjects)
124
125 // Attach image to RC
126 // Should assume defaults up tree creating necessary components
127 err := rc.Attach(imageEntity)
128 assert.NoError(t, err, "attachment should be allowed")
129
130 // Compare internal elements
131 assert.NotNil(t, rc.pod, "should of created template")
132
133 // Create struct representation for expected
134 expectedRC := &kube.ReplicationController{
135 ObjectMeta: kube.ObjectMeta{
136 Name: rcName,
137 Namespace: kube.NamespaceDefault,
138 },
139 Spec: kube.ReplicationControllerSpec{
140 Selector: selector,
141 Template: &kube.PodTemplateSpec{
142 ObjectMeta: kube.ObjectMeta{
143 Namespace: kube.NamespaceDefault,
144 Labels: selector,
145 },
146 Spec: kube.PodSpec{
147 Containers: []kube.Container{
148 {
149 Name: imageName,
150 Image: imageName,
151 ImagePullPolicy: kube.PullAlways,
152 },
153 },
154 RestartPolicy: kube.RestartPolicyAlways,
155 DNSPolicy: kube.DNSDefault,
156 },
157 },
158 },
159 }
160
161 // Insert into Deployment
162 expected := new(deploy.Deployment)
163 err = expected.Add(expectedRC)
164 assert.NoError(t, err, "should be valid RC")
165
166 // add objects to deployment
167 expected.AddDeployment(imageEntity.objects)

Callers

nothing calls this directly

Calls 10

testNewRCFunction · 0.85
testNewImageFunction · 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