Fork me on GitHub
#datomic
<
2020-02-06
>
tatut13:02:30

in datomic cloud there is no possibility to do in-memory unit tests without a connection to the cloud instance?

tatut13:02:47

FAQ seems to state that

tatut13:02:01

do people usually have test suites use an actual instance?

👍 4
tatut13:02:28

ok, good to know

favila13:02:08

there is a library which implements the client api against the peer api designed for testing, it’s name escapes me

favila13:02:47

it’s not perfect and you need an on-prem license

favila13:02:03

but it’s something

jeremyvdw14:02:32

Depending of your us-case, you can have to look to https://github.com/vvvvalvalval/datomock

kenny16:02:05

@U11SJ6Q0K We wrote that library (I don't like the name but people started using it before we could change it haha). We really wanted to embrace the whole "test against the production system" but it's just too much of a pain. CI tests need to run the socks proxy to connect to the Datomic instance. IIRC, we never managed to get that set up in a stable way on CircleCI. It was almost there (again IIRC) but we needed to be able to control the hostname for the socks proxy. The Datomic team said they'd add it but that was 2 years ago or so. Further, you need a way to have developers create databases with the same name (e.g., "admin") but not trip over each other by transacting to the same database. You'll need to write something to handle that as well. You could have each dev run their own Datomic Cloud system but that gets unwieldy. If you're using Ions, you'll probably need to do that. Finally, the ability to test in memory is simply quite nice. I may not always have a stable internet connection (e.g., working in a cafe, on a plane, etc) and don't want to be blocked from developing. I wish the Datomic team would release an official in-memory implementation for testing. All that being said, we do run integration tests against the Datomic Cloud system.

tatut17:02:40

yes, I really wish there was an in-memory impl for testing purposes as well... the socks proxy situation seems tricky to set up for ci

tatut17:02:17

I don't see the database name as a problem though, your tests can always setup a unique name and we use $USER-dev named databases for all developers

kenny17:02:01

Yes, if you place all your data in a single database, the naming shouldn't be an issue.

joshkh19:02:05

after a long battle, we managed to get the socks-proxy running on CircleCI

kenny19:02:12

Nice! You should make a post on the Datomic forum about how you did it.

joshkh19:02:27

that's a great idea. i'll confirm that the work is shareable and then hopefully follow up with a post.

joshkh19:02:50

@U11SJ6Q0K we've also had some success building and then testing against an in-memory datahike database: https://github.com/replikativ/datahike you won't be able to test things like Datomic query and transaction functions, but it's a fun idea and faster than querying a database value returned by d/with-db . and of course it isn't "as real" as using Datomic itself.

joshkh19:02:39

Assuming I have the attribute :user/id in my schema, is this a valid datomic/metaschema.edn to generate a table?

{:tables {:user/id {}}}
I'm unable to see my table, although I can connect with my schema and catalog and can see the db__attrs and db__idents tables, and so the Troubleshooting docs suggest it's a problem with the metaschema itself. I've tried syncing and cycling my datomic-access connection and presto connection with no luck.

joshkh20:02:42

Came back to it later and it's working. Cool.