createRun method
Opens an adapter-owned test run and returns its id.
Implementation
Future<int> createRun() async {
const label = 'create run';
final url = Uri.parse(
'${config.baseURL}/projects/${config.projectId}/test-runs/autotest',
);
final title = config.runTitle.trim();
final _Response response;
try {
response = await _send(
'POST',
url,
headers: _headers(json: title.isNotEmpty),
body: title.isEmpty
? null
: utf8.encode(jsonEncode(<String, String>{'title': title})),
);
} on Object catch (error) {
throw ApiError('$label failed: $error');
}
if (response.statusCode >= 400) {
throw ApiError(
'$label failed: HTTP ${response.statusCode} ${response.body.trim()}',
);
}
final id = _decodeObject(response.body, label)['id'];
if (id is! int || id < 1) {
throw const ApiError('$label failed: server returned no run id');
}
return id;
}