Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View mtharrison's full-sized avatar

Matt Harrison mtharrison

View GitHub Profile
@mtharrison
mtharrison / main.c
Last active November 20, 2017 03:50
Simulate MT unsafe issues https://github.com/libuv/libuv/issues/271
#include <assert.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <uv.h>
static int iterations = 0;
'use strict';
// The whole app is a hapi plugin
module.exports = function (server, options, next) {
server.route({
method: 'GET',
path: '/add/{a}/{b}',
handler: function (request, reply) {

An question I've seen several times popping up in hapi issues is how to get an initialized hapi server into your tests. There's a few patterns I've seen in common use so I thought I'd document them somewhere.

Here's the test we're going to use as an example:

it('Can add two numbers', (done) => {

    server.inject('/add/1/5', (res) => {
  
        expect(res.statusCode).to.equal(200);
'use strict';
const Hapi = require('hapi');
const server = new Hapi.Server();
server.connection({ port: 4000 });
server.auth.scheme('payload', function (server, options) {
return {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example</title>
</head>
<body>
<script>
var request = new XMLHttpRequest();
request.open('POST', 'http://localhost:3000/tokens', true);
127.0.0.1 example.com
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
var request = new XMLHttpRequest();
request.open('GET', 'http://127.0.0.1:4000/cors', true);
.equ PORTB,0x05
.equ DDRB, 0x04
.global main
main:
ldi r16, 0b00000001
out DDRB,r16
loop:
out PORTB,r16
rjmp loop
var Hapi = require('hapi');
var Request = require('request');
var server = new Hapi.Server();
server.connection({ port: 4000});
server.route({
method: 'GET',
path: '/cookies',
handler: function (request, reply) {
var Benchmark = require('benchmark');
var Hapi = require('hapi');
var Wreck = require('wreck');
var server = new Hapi.Server();
server.connection({ port: 4000 });
server.register(require('h2o2'), function () {});
var asyncBench = function(name, bench, callback) {