Skip to content

Commit 6f81b61

Browse files
Fix specs that no longer work after test framework updates
1 parent a0b1f4f commit 6f81b61

File tree

2 files changed

+109
-138
lines changed

2 files changed

+109
-138
lines changed

Diff for: test/spec/services/applicationGeneratorSpec.js

+66-70
Original file line numberDiff line numberDiff line change
@@ -255,77 +255,73 @@ describe("ApplicationGenerator", function(){
255255
});
256256

257257
it("should generate a BuildConfig for the source", function(){
258-
expect(resources.buildConfig).toEqual(
258+
var generatedBuildConfig = resources.buildConfig;
259+
260+
expect(generatedBuildConfig.apiVersion).toEqual('v1');
261+
expect(generatedBuildConfig.kind).toEqual('BuildConfig');
262+
expect(generatedBuildConfig.metadata.name).toEqual('ruby-hello-world');
263+
expect(generatedBuildConfig.metadata.labels).toEqual({
264+
"foo" : "bar",
265+
"abc" : "xyz"
266+
});
267+
expect(generatedBuildConfig.metadata.annotations).toEqual({
268+
"openshift.io/generated-by": "OpenShiftWebConsole"
269+
});
270+
expect(generatedBuildConfig.spec.output).toEqual({
271+
"to": {
272+
"name": "ruby-hello-world:latest",
273+
"kind": "ImageStreamTag"
274+
}
275+
});
276+
expect(generatedBuildConfig.spec.source).toEqual({
277+
"git": {
278+
"ref": "master",
279+
"uri": "https://github.com/openshift/ruby-hello-world.git"
280+
},
281+
"type": "Git"
282+
});
283+
expect(generatedBuildConfig.spec.strategy.type).toEqual('Source');
284+
285+
expect(generatedBuildConfig.spec.strategy.sourceStrategy.from.kind).toEqual('ImageStreamTag');
286+
expect(generatedBuildConfig.spec.strategy.sourceStrategy.from.name).toEqual('origin-ruby-sample:latest');
287+
expect(generatedBuildConfig.spec.strategy.sourceStrategy.from).toEqual({
288+
"kind": "ImageStreamTag",
289+
"name": "origin-ruby-sample:latest",
290+
"namespace": undefined
291+
});
292+
expect(generatedBuildConfig.spec.strategy.sourceStrategy.env).toEqual([
259293
{
260-
"apiVersion": "v1",
261-
"kind": "BuildConfig",
262-
"metadata": {
263-
"name": "ruby-hello-world",
264-
"labels": {
265-
"foo" : "bar",
266-
"abc" : "xyz"
267-
},
268-
"annotations": {
269-
"openshift.io/generated-by": "OpenShiftWebConsole"
270-
}
271-
},
272-
"spec": {
273-
"output": {
274-
"to": {
275-
"name": "ruby-hello-world:latest",
276-
"kind": "ImageStreamTag"
277-
}
278-
},
279-
"source": {
280-
"git": {
281-
"ref": "master",
282-
"uri": "https://github.com/openshift/ruby-hello-world.git"
283-
},
284-
"type": "Git"
285-
},
286-
"strategy": {
287-
"type": "Source",
288-
"sourceStrategy" : {
289-
"from": {
290-
"kind": "ImageStreamTag",
291-
"name": "origin-ruby-sample:latest"
292-
},
293-
"env": [
294-
{
295-
"name": "BUILD_ENV_1",
296-
"value": "someValue"
297-
},
298-
{
299-
"name": "BUILD_ENV_2",
300-
"value": "anotherValue"
301-
}
302-
]
303-
}
304-
},
305-
"triggers": [
306-
{
307-
"generic": {
308-
"secret": "secret101"
309-
},
310-
"type": "Generic"
311-
},
312-
{
313-
"github": {
314-
"secret": "secret101"
315-
},
316-
"type": "GitHub"
317-
},
318-
{
319-
"imageChange" : {},
320-
"type" : "ImageChange"
321-
},
322-
{
323-
"type": "ConfigChange"
324-
}
325-
]
326-
}
327-
}
328-
);
294+
"name": "BUILD_ENV_1",
295+
"value": "someValue"
296+
},
297+
{
298+
"name": "BUILD_ENV_2",
299+
"value": "anotherValue"
300+
}
301+
]);
302+
303+
expect(generatedBuildConfig.spec.triggers).toEqual([
304+
{
305+
"generic": {
306+
"secret": "secret101"
307+
},
308+
"type": "Generic"
309+
},
310+
{
311+
"github": {
312+
"secret": "secret101"
313+
},
314+
"type": "GitHub"
315+
},
316+
{
317+
"imageChange" : {},
318+
"type" : "ImageChange"
319+
},
320+
{
321+
"type": "ConfigChange"
322+
}
323+
]);
324+
329325
});
330326

331327
it("should generate an ImageStream for the build output", function(){

Diff for: test/spec/services/membership/membershipSpec.js

+43-68
Original file line numberDiff line numberDiff line change
@@ -236,74 +236,49 @@ describe('MembershipService', function() {
236236
// NOTE: ideally the above tests catch any issues as they do a better job of
237237
// declaring intent, if not, this test will compare raw output.
238238
it('should build a map for the tabbed role list interface', function() {
239-
expect(MembershipService.mapRolebindingsForUI(roleBindings, keyedRoles))
240-
.toEqual([{
241-
"kind": "User",
242-
"sortOrder": 1,
243-
"name": "User",
244-
"subjects": {
245-
"-jill": {
246-
"name": "jill",
247-
"roles": {
248-
"ClusterRole-admin": {
249-
"kind": "ClusterRole",
250-
"metadata": {
251-
"name": "admin"
252-
}
253-
},
254-
"ClusterRole-view": {
255-
"kind": "ClusterRole",
256-
"metadata": {
257-
"name": "view"
258-
}
259-
}
260-
}
261-
},
262-
"-jack": {
263-
"name": "jack",
264-
"roles": {
265-
"ClusterRole-edit": {
266-
"kind": "ClusterRole",
267-
"metadata": {
268-
"name": "edit"
269-
}
270-
}
271-
}
272-
}
273-
}
274-
}, {
275-
"kind": "Group",
276-
"sortOrder": 2,
277-
"name": "Group",
278-
"subjects": {}
279-
}, {
280-
"kind": "ServiceAccount",
281-
"sortOrder": 3,
282-
"description": "Service accounts provide a flexible way to control API access without sharing a regular user’s credentials.",
283-
"helpLinkKey": "service_accounts",
284-
"name": "ServiceAccount",
285-
"subjects": {
286-
"fake-project-foo": {
287-
"name": "foo",
288-
"namespace": "fake-project",
289-
"roles": {}
290-
}
291-
}
292-
}, {
293-
"kind": "SystemUser",
294-
"sortOrder": 4,
295-
"description": "System users are virtual users automatically provisioned by the system.",
296-
"helpLinkKey": "users_and_groups",
297-
"name": "SystemUser",
298-
"subjects": {}
299-
}, {
300-
"kind": "SystemGroup",
301-
"sortOrder": 5,
302-
"description": "System groups are virtual groups automatically provisioned by the system.",
303-
"helpLinkKey": "users_and_groups",
304-
"name": "SystemGroup",
305-
"subjects": {}
306-
}]);
239+
240+
var mappedRoleBindings = MembershipService.mapRolebindingsForUI(roleBindings, keyedRoles);
241+
var userBinding = mappedRoleBindings[0];
242+
var groupBinding = mappedRoleBindings[1];
243+
var serviceAccountBinding = mappedRoleBindings[2];
244+
var systemUserBinding = mappedRoleBindings[3];
245+
var systemGroupBinding = mappedRoleBindings[4];
246+
247+
expect(userBinding.kind).toEqual('User');
248+
expect(userBinding.sortOrder).toEqual(1);
249+
expect(userBinding.name).toEqual('User');
250+
expect(_.size(userBinding.subjects)).toEqual(2);
251+
expect(_.map(userBinding.subjects, 'name')).toEqual(['jill', 'jack']);
252+
expect( _.keys(userBinding.subjects['-jill'].roles) ).toEqual(['ClusterRole-admin', 'ClusterRole-view']);
253+
expect( _.map(userBinding.subjects['-jill'].roles, 'metadata.name') ).toEqual(['admin', 'view']);
254+
expect( _.keys(userBinding.subjects['-jack'].roles) ).toEqual(['ClusterRole-edit']);
255+
expect( _.map(userBinding.subjects['-jack'].roles, 'metadata.name') ).toEqual(['edit']);
256+
257+
expect(groupBinding).toEqual({
258+
kind: 'Group',
259+
sortOrder: 2,
260+
name: 'Group',
261+
subjects: {}
262+
});
263+
264+
expect(serviceAccountBinding.kind).toEqual('ServiceAccount');
265+
expect(serviceAccountBinding.sortOrder).toEqual(3);
266+
expect(serviceAccountBinding.description).toEqual('Service accounts provide a flexible way to control API access without sharing a regular user’s credentials.');
267+
expect(serviceAccountBinding.name).toEqual('ServiceAccount');
268+
expect(serviceAccountBinding.helpLinkKey).toEqual('service_accounts');
269+
expect(serviceAccountBinding.subjects['fake-project-foo'].name).toEqual('foo');
270+
expect(serviceAccountBinding.subjects['fake-project-foo'].namespace).toEqual('fake-project');
271+
272+
expect(systemUserBinding.kind).toEqual('SystemUser');
273+
expect(systemUserBinding.sortOrder).toEqual(4);
274+
expect(systemUserBinding.description).toEqual('System users are virtual users automatically provisioned by the system.');
275+
expect(systemUserBinding.helpLinkKey).toEqual('users_and_groups');
276+
277+
expect(systemGroupBinding.kind).toEqual('SystemGroup');
278+
expect(systemGroupBinding.sortOrder).toEqual(5);
279+
expect(systemGroupBinding.description).toEqual('System groups are virtual groups automatically provisioned by the system.');
280+
expect(systemGroupBinding.helpLinkKey).toEqual('users_and_groups');
281+
307282
});
308283
});
309284

0 commit comments

Comments
 (0)