Back to articles
Unit testing with SeaOrm

Unit testing with SeaOrm

via Dev.toMila Kyrashchuk

A few weeks ago, I submitted my BSc thesis and project, where I developed the identity management application. The API was implemented in Rust, with Actix-Web framework, and SeaOrm for database communication. The University's expectation was to create a Django backend and HTML+CSS frontend, and cover them with unit-tests. However when it came to mocking Postgres connection with SeaOrm, I quickly became confused. The SeaOrm provides a MockDatabase (which is great!), but to use it we must fill it with query or execution results first. The documentation has an overview for the basic find and insert methods, others are scarcely mentioned in various StackOverflow answers. This post describes the logic and code snippets, that I had to mock for my project: update / save, select partial model or a tuple, and delete cascade. Let's assume we're building the application for the vet clinic for dogs, and the part of the database design includes the following relationships: Update and Save While sav

Continue reading on Dev.to

Opens in a new tab

Read Full Article
0 views

Related Articles