zlib.tap.js 709 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. var tap = require('tap')
  3. , test = tap.test
  4. , createNamespace = require('../context.js').createNamespace
  5. ;
  6. var zlib = require('zlib');
  7. test("continuation-local state with zlib", function (t) {
  8. t.plan(1);
  9. var namespace = createNamespace('namespace');
  10. namespace.run(function () {
  11. namespace.set('test', 0xabad1dea);
  12. t.test("deflate", function (t) {
  13. namespace.run(function () {
  14. namespace.set('test', 42);
  15. zlib.deflate(new Buffer("Goodbye World"), function (err) {
  16. if (err) throw err;
  17. t.equal(namespace.get('test'), 42, "mutated state was preserved");
  18. t.end();
  19. });
  20. });
  21. });
  22. });
  23. });