test logs can now be used to validate number of occurences

pull/1137/head
Audric Ackermann 5 years ago
parent 35cbb4cdd6
commit 76e5992994
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -558,7 +558,7 @@ module.exports = {
if (pubkey) {
if (request.method === 'POST') {
if (ENABLE_LOG) {
console.warn('POST', [data, timestamp]);
console.warn('POST for', pubkey, [data, timestamp]);
}
let ori = this.messages[pubkey];
@ -571,9 +571,10 @@ module.exports = {
response.writeHead(200, { 'Content-Type': 'text/html' });
response.end();
} else {
const retrievedMessages = { messages: this.messages[pubkey] };
const messages = this.messages[pubkey] || [];
const retrievedMessages = { messages };
if (ENABLE_LOG) {
console.warn('GET', pubkey, retrievedMessages);
console.warn('GET for', pubkey, retrievedMessages);
}
if (this.messages[pubkey]) {
response.writeHead(200, { 'Content-Type': 'application/json' });
@ -638,12 +639,17 @@ module.exports = {
* @param {*} str the string to search (not regex)
* Note: getRenderProcessLogs() clears the app logs each calls.
*/
async logsContains(renderLogs, str) {
const found = renderLogs.some(log => log.message.includes(str));
async logsContains(renderLogs, str, count = undefined) {
const foundLines = renderLogs.filter(log => log.message.includes(str));
// eslint-disable-next-line no-unused-expressions
chai.expect(found, `'${str}' not found in logs but was expected`).to.be
chai.expect(foundLines.length > 0, `'${str}' not found in logs but was expected`).to.be
.true;
if (count) {
// eslint-disable-next-line no-unused-expressions
chai.expect(foundLines.length, `'${str}' found but not the correct number of times`).to.be.equal(count);
}
},
// async killStubSnodeServer() {

Loading…
Cancel
Save