Fix for wrong JSON format on OSTF tab
- iterating over testsets, not tests Closes-bug: #1466468 Change-Id: Ic19c489833b3ad8c5c21e7445997bbe3e30a8cff
This commit is contained in:
parent
233b8345f9
commit
78677f8e9a
@ -141,38 +141,45 @@ 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 = [];
|
||||
if (testruns.length) {
|
||||
requests.push(Backbone.sync('create', testruns));
|
||||
|
Loading…
Reference in New Issue
Block a user