Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test repository [exposed]? #1977

Open
LookBad opened this issue Jun 28, 2020 · 3 comments
Open

How to test repository [exposed]? #1977

LookBad opened this issue Jun 28, 2020 · 3 comments

Comments

@LookBad
Copy link

LookBad commented Jun 28, 2020

Hi!

I need to know how can I test my repository. For example:

class AdminRepositoryImpl : AdminRepository {
    override fun create(builder: AdminParams): Int {
        return transaction {
            Admins.insert {
                it[login] = builder.login
                it[password] = builder.password
                it[createdAt] = DateTime.now()
            }[Admins.id].value
        }
    }
}

How can I test it? I use ktor + exposed, so I thought that "withTestApplication" will be work but it doesn't .

@hhariri
Copy link
Contributor

hhariri commented Jun 30, 2020

What is the purpose of the test? Is it to test storage/exposed? Or routes in Ktor? Based on that, then different solutions are possible. If it's about testing storage I'd recommend doing this outside of a Ktor test, and using something like TestContainers.

@LookBad
Copy link
Author

LookBad commented Jul 3, 2020

I want to test repository, check that methods return correct values.

@TheReprator
Copy link

TheReprator commented Apr 1, 2021

like i want to test the database portion, so i can i make sure, whether database is correctly inserted or not with test with the command, i gave @hhariri @e5l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants