question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some typo in tests

See original GitHub issue

Hi this test actually return 3 but expected to be 2 which is wrong

Deno.test("adds the element", async () => {
  const key = newKey();
  const value1 = randomID();
  const value2 = randomID();

  await new LPushCommand([key, value1]).exec(client);
  const res = await new LInsertCommand([key, "before", value1, value2]).exec(
    client,
  );
  assertEquals(res, 2);
});

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:15

github_iconTop GitHub Comments

1reaction
rebaz94commented, Jul 12, 2022

@chronark I have one question about spop command why the TResult type parameter is string? if count defined the result will be list of string

export class SPopCommand<TData> extends Command<
  string | null, // i think it should be string[] | string | null
  TData | null
> {
  constructor(
    [key, count]: [key: string, count?: number],
    opts?: CommandOptions<string | null, TData | null>,
  ) {
    const command: unknown[] = ["spop", key];
    if (typeof count === "number") {
      command.push(count);
    }
    super(command, opts);
  }
}
1reaction
rebaz94commented, Jul 12, 2022

according to Redis documentation for spop Removes and returns one or more random members from the set value store at key.

but in the test said return the first element

Deno.test("without count", async (t) => {
  await t.step("returns the first element", async () => {
    const key = newKey();
    const member = randomID();
    await new SAddCommand([key, member]).exec(client);
    const res = await new SPopCommand([key]).exec(client);
    assertEquals(res, member);
  });
});

Deno.test("with count", async (t) => {
  await t.step("returns the first n elements", async () => {
    const key = newKey();
    const member1 = randomID();
    const member2 = randomID();
    const member3 = randomID();
    const member4 = randomID();
    await new SAddCommand([key, member1, member2, member3, member4]).exec(
      client,
    );
    const res = await new SPopCommand<string[]>([key, 2]).exec(client);

    assertEquals(res?.length, 2);
    assertEquals([member1, member2, member3, member4].includes(res![0]), true);
    assertEquals([member1, member2, member3, member4].includes(res![1]), true);
  });
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Typos Should be High-Priority Bugs - Applause
Brand reputation matters more than ever, so a simple misspelling can ... Unsurprisingly, I found a few bugs; that's why we test after...
Read more >
Is checking web content for typos and spelling mistakes part of ...
While testing, you see that one of the existing information pages of the website contains some spelling mistake.
Read more >
Typo in Writing Sample - 7Sage Forum
Hey everyone, So I just wrote my writing sample (my test is tomorrow) and everything went really well, I had strong arguments etc....
Read more >
Typo (Typographical Error) | What is One Example of a Typo?
In some cases, what spell check classifies as typos are written on purpose and will not be corrected, but others can be accidental...
Read more >
CITY SCHOOL EXAMS FAIL THE 'TYPO' TEST - New York Post
Some 90 different exams were created for the empowerment schools – though some questions were the same on all the tests. Each of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found