mirror of https://github.com/lukechilds/got.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
868 B
43 lines
868 B
9 years ago
|
import {format} from 'util';
|
||
|
import tempfile from 'tempfile';
|
||
|
import test from 'ava';
|
||
|
import got from '../';
|
||
9 years ago
|
import {createServer} from './_server';
|
||
9 years ago
|
|
||
9 years ago
|
const s = createServer();
|
||
|
const socketPath = tempfile('.socket');
|
||
9 years ago
|
|
||
9 years ago
|
s.on('/', (req, res) => {
|
||
9 years ago
|
res.end('ok');
|
||
|
});
|
||
|
|
||
9 years ago
|
test.before('unix-socket - setup', t => {
|
||
|
s.listen(socketPath, () => t.end());
|
||
9 years ago
|
});
|
||
|
|
||
9 years ago
|
test('unix-socket - request via unix socket', t => {
|
||
9 years ago
|
// borrow unix domain socket url format from request module
|
||
9 years ago
|
const url = format('http://unix:%s:%s', socketPath, '/');
|
||
9 years ago
|
|
||
9 years ago
|
got(url, (err, data) => {
|
||
9 years ago
|
t.ifError(err);
|
||
|
t.is(data, 'ok');
|
||
9 years ago
|
t.end();
|
||
|
});
|
||
|
});
|
||
|
|
||
9 years ago
|
test('unix-socket - protocol-less request', t => {
|
||
|
const url = format('unix:%s:%s', socketPath, '/');
|
||
9 years ago
|
|
||
9 years ago
|
got(url, (err, data) => {
|
||
9 years ago
|
t.ifError(err);
|
||
|
t.is(data, 'ok');
|
||
9 years ago
|
t.end();
|
||
|
});
|
||
|
});
|
||
|
|
||
9 years ago
|
test.after('unix-socket - cleanup', t => {
|
||
9 years ago
|
s.close();
|
||
|
t.end();
|
||
|
});
|