Testing with document Ids as a field
Trying out convex test and this code is resulting in an error, do I need to test create a record in the orgs table and then send that to the test mutation & match?
error:
2 Replies
I'd create an org ID with
db.insert
. Note you can do something like this:
and don't have to write a new mutation just for testing.
To share some of the details about the implementation here, validators like v.id("orgs")
want to be able to distinguish between an ID in the "orgs" table and an ID in the "tasks" table. In tests, we make our IDs look like orgs;1
(or something like that), and do something fancier in production. But this is why generating a UUID isn't quite enough.
We could potentially make something like t.allocateNewId("orgs")
if it's useful, but hopefully creating a test entry in the orgs table isn't too bad?Ah make sense, this approach works great — thanks!