it('should app.curl work on lookup error', async () => { const result = await app.curl(url + '/get_headers', { dataType: 'json' }); assert(result.status === 200); assert(result.data.host === host); // mock local cache expires and mock dns lookup throw error app.httpclient.dnsCache.get('localhost').timestamp = 0; mm.error(dns, 'lookup', 'mock dns lookup error'); const result2 = await app.httpclient.curl(url + '/get_headers', { dataType: 'json' }); assert(result2.status === 200); assert(result2.data.host === host); });
it('should use local cache dns result when dns lookup error', async () => { await app.httpRequest() .get('/?url=' + encodeURIComponent(url + '/get_headers')) .expect(200) .expect(/"host":"localhost:\d+"/); // mock local cache expires and mock dns lookup throw error app.httpclient.dnsCache.get('localhost').timestamp = 0; mm.error(dns, 'lookup', 'mock dns lookup error'); await app.httpRequest() .get('/?url=' + encodeURIComponent(url + '/get_headers')) .expect(200) .expect(/"host":"localhost:\d+"/); });