Fix for wrong JSON format on OSTF tab

- iterating over testsets, not tests

Closes-bug: #1466468

Change-Id: Ic19c489833b3ad8c5c21e7445997bbe3e30a8cff
This commit is contained in:
Alexandra Morozova 2015-06-19 09:49:40 +02:00
parent 126e50e624
commit dbd5415881
1 changed files with 35 additions and 29 deletions

View File

@ -139,36 +139,42 @@ function($, _, i18n, Backbone, React, models, utils, componentMixins, controls)
runTests: function() {
var testruns = new models.TestRuns(),
oldTestruns = new models.TestRuns(),
selectedTests = this.props.tests.where({checked: true});
testsetIds = this.props.testsets.pluck('id');
this.setState({actionInProgress: true});
_.each(selectedTests, function(test) {
var testsetId = test.get('testset'),
testrunConfig = {tests: _.pluck(selectedTests, 'id')},
addCredentials = _.bind(function(obj) {
obj.ostf_os_access_creds = {
ostf_os_username: this.state.credentials.user,
ostf_os_tenant_name: this.state.credentials.tenant,
ostf_os_password: this.state.credentials.password
};
return obj;
}, this);
if (this.props.testruns.where({testset: testsetId}).length) {
_.each(this.props.testruns.where({testset: testsetId}), function(testrun) {
_.extend(testrunConfig, addCredentials({
id: testrun.id,
status: 'restarted'
}));
oldTestruns.add(new models.TestRun(testrunConfig));
}, this);
} else {
_.extend(testrunConfig, {
testset: testsetId,
metadata: addCredentials({
config: {},
cluster_id: this.props.cluster.id
})
});
testruns.add(new models.TestRun(testrunConfig));
_.each(testsetIds, function(testsetId) {
var testsToRun = _.pluck(this.props.tests.where({
testset: testsetId,
checked: true
}), 'id');
if (testsToRun.length) {
var testrunConfig = {tests: testsToRun},
addCredentials = _.bind(function(obj) {
obj.ostf_os_access_creds = {
ostf_os_username: this.state.credentials.user,
ostf_os_tenant_name: this.state.credentials.tenant,
ostf_os_password: this.state.credentials.password
};
return obj;
}, this);
if (this.props.testruns.where({testset: testsetId}).length) {
_.each(this.props.testruns.where({testset: testsetId}), function(testrun) {
_.extend(testrunConfig, addCredentials({
id: testrun.id,
status: 'restarted'
}));
oldTestruns.add(new models.TestRun(testrunConfig));
}, this);
} else {
_.extend(testrunConfig, {
testset: testsetId,
metadata: addCredentials({
config: {},
cluster_id: this.props.cluster.id
})
});
testruns.add(new models.TestRun(testrunConfig));
}
}
}, this);
var requests = [];