GithubHelp home page GithubHelp logo

stack-auth / pgmock Goto Github PK

View Code? Open in Web Editor NEW
1.1K 1.1K 19.0 40.18 MB

In-memory Postgres for unit/E2E tests

Home Page: https://stackframe-projects.github.io/pgmock/

License: MIT License

TypeScript 18.47% JavaScript 81.53%

pgmock's People

Contributors

n2d4 avatar zfben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pgmock's Issues

Improve migration performance

Currently, migration took about 20-30 seconds which is too slow for testing.
We also need to reset db after each test so 20-30 seconds wait time between each tests is not viable.
We need a solution for this, so we can bring it down to sub 1 second.

Improve documentation

Right now, the only documentation is the docstrings in the source code. I should generate a webpage from those

Errors aren't correctly displayed when using Firefox

As reported here, when pgmock is unhappy with a SQL query it throws an unexpected error instead of showing the details:

select foo();
Error.captureStackTrace is not a function

Fortunately, @rezonant was quickly able to explain the likely problem (this is a Firefox specific issue), which should help get this fixed:

Yes, that's a nonstandard function provided by v8, so it wouldn't work on Firefox. [1]

This can be worked around by just constructing an Error and taking it's stack property,
captureStackTrace is just a convenience function, so hopefully they can fix that.

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#error.capturestacktrace

How hard would it be to adapt this abstraction to MySQL?

Hey ๐Ÿ‘‹ ,

I'm one of the developers who worked on https://github.com/snaplet/postgres-wasm, I'm super happy to see that our work helped and that you were able to pull this off to make it usable! I added a shoutout to this project in the README. ๐Ÿ˜

I see that you wrote an entire network adapter for it which I suppose is at the emulator level, so I'm wondering how hard it would be to have MySQL running in the browser now.

Again, congrats, mad work!

Failed to create extension`uuid-ossp`

When trying to run:

create extension if not exists "uuid-ossp";

it fails with

error: could not open extension control file "/usr/share/postgresql/extension/uuid-ossp.control": No such file or directory
    at <anonymous> (/Users/scott/project/node_modules/pg/lib/client.js:526:17)

Is this meant to be supported? Or is there a specific process to get extensions working?

Demo link give 404

The link to the demo / GitHub pages link gives a 404 / page not found.

RangeError: Maximum call stack size exceeded

I'm trying to add pgmock in our E2E testing suite using NestJS, TypeORM + Jest.

I get the following error thrown though:

Unhandled Rejection at: Promise {
      <rejected> TypeError: Cannot read properties of undefined (reading '0')
          at Object.<anonymous>.r.Bitmap.get (/<REDACTED>/node_modules/pgmock/dist/main.js:3039:25)
          at E.Object.<anonymous>.E.unpack_memory (/<REDACTED>/node_modules/pgmock/dist/main.js:10548:19)
          at E.Object.<anonymous>.E.set_state (/<REDACTED>/node_modules/pgmock/dist/main.js:10491:14)
          at E.Object.<anonymous>.E.restore_state (/<REDACTED>/node_modules/pgmock/dist/main.js:8124:18)
          at D.Object.<anonymous>.D.restore_state (/<REDACTED>/node_modules/pgmock/dist/main.js:2881:25)
          at Y.d (/<REDACTED>/node_modules/pgmock/dist/main.js:12413:35)
          at listOnTimeout (node:internal/timers:569:17)
          at processTimers (node:internal/timers:512:7)
    } reason: TypeError: Cannot read properties of undefined (reading '0')
        at Object.<anonymous>.r.Bitmap.get (/<REDACTED>/node_modules/pgmock/dist/main.js:3039:25)
        at E.Object.<anonymous>.E.unpack_memory (/<REDACTED>/node_modules/pgmock/dist/main.js:10548:19)
        at E.Object.<anonymous>.E.set_state (/<REDACTED>/node_modules/pgmock/dist/main.js:10491:14)
        at E.Object.<anonymous>.E.restore_state (/<REDACTED>/node_modules/pgmock/dist/main.js:8124:18)
        at D.Object.<anonymous>.D.restore_state (/<REDACTED>/node_modules/pgmock/dist/main.js:2881:25)
        at Y.d (/<REDACTED>/node_modules/pgmock/dist/main.js:12413:35)
        at listOnTimeout (node:internal/timers:569:17)
        at processTimers (node:internal/timers:512:7)

...

RangeError: Maximum call stack size exceeded

      at _ZN3v863cpu3cpu12do_page_walk17h3226b305185b420aE (wasm:/wasm/0060a6c6:1:471691)
      at _ZN3v863cpu3cpu21call_interrupt_vector17h15f125d3196b6ae5E (wasm:/wasm/0060a6c6:1:734657)
      at _ZN3v863cpu3cpu12do_page_walk17h3226b305185b420aE (wasm:/wasm/0060a6c6:1:472412)
      at _ZN3v863cpu3cpu21call_interrupt_vector17h15f125d3196b6ae5E (wasm:/wasm/0060a6c6:1:734657)
      at _ZN3v863cpu3cpu12do_page_walk17h3226b305185b420aE (wasm:/wasm/0060a6c6:1:472412)
      at _ZN3v863cpu3cpu21call_interrupt_vector17h15f125d3196b6ae5E (wasm:/wasm/0060a6c6:1:734657)
      at _ZN3v863cpu3cpu12do_page_walk17h3226b305185b420aE (wasm:/wasm/0060a6c6:1:472412)
      at _ZN3v863cpu3cpu21call_interrupt_vector17h15f125d3196b6ae5E (wasm:/wasm/0060a6c6:1:734657)
      at _ZN3v863cpu3cpu12do_page_walk17h3226b305185b420aE (wasm:/wasm/0060a6c6:1:472412)
      at _ZN3v863cpu3cpu21call_interrupt_vector17h15f125d3196b6ae5E (wasm:/wasm/0060a6c6:1:734657)
      at _ZN3v863cpu3cpu12do_page_walk17h3226b305185b420aE (wasm:/wasm/0060a6c6:1:472412)
      at _ZN3v863cpu3cpu21call_interrupt_vector17h15f125d3196b6ae5E (wasm:/wasm/0060a6c6:1:734657)
      at _ZN3v863cpu3cpu12do_page_walk17h3226b305185b420aE (wasm:/wasm/0060a6c6:1:472412)

Any ideas what this might indicate?

how do i use with jest/typescript?

no amount of transform ignore stuff seems to work

is there a standard way? i just get this:

import nodecrypto from "crypto";
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

How to add pg extensions

How would I add pg extensions, e.g. pgvector, to pgmock? I see the binaries folder and assume that's where the secret source is. It would be nice if there were documentation on how to generate them, or even better, a script. Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.