Welcome to the Linux Foundation Forum!

Lab 16.3 April 2021 edition

My test for the failure case works fine. My test for the success case times out. If I promisify the callback based store from lab 2, my test passes and I can see that it is in fact waiting. Am I doing something wrong or is there something wrong with the lab?

const store = require('./store');
const { promisify } = require('util')
const store2 = promisify(require('../labs-2/store'));

describe("store", () => {
//SUCCEEDS
it("should throw if not given a buffer", async () => {
try {
await store("bad");
} catch (err) {
expect(err).toEqual(new Error("input must be a buffer"));
}
});

  1. //SUCCEEDS and has a delay between the console.logs
  2. it("should return an id with a length of 4 given a buffer", async () => {
  3. console.log(new Date())
  4. const result = await store2(Buffer.from("good"));
  5. console.log(new Date())
  6. expect(result.id.length).toBe(4);
  7. });
  8.  
  9. //Times out
  10. it("should return an id with a length of 4 given a buffer", async () => {
  11. console.log(new Date())
  12. const result = await store(Buffer.from("good"));
  13. console.log(new Date())
  14. expect(result.id.length).toBe(4);
  15. });

});

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training