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

1605: Add tests for import accepting stores mutation #1643

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ enum class TestAdministrators(
project = "bayern.ehrenamtskarte.app",
email = "[email protected]",
role = Role.PROJECT_ADMIN
),
NUERNBERG_PROJECT_STORE_MANAGER(
project = "nuernberg.sozialpass.app",
email = "[email protected]",
role = Role.PROJECT_STORE_MANAGER
),
NUERNBERG_PROJECT_ADMIN(
project = "nuernberg.sozialpass.app",
email = "[email protected]",
role = Role.PROJECT_ADMIN
);

fun getJwtToken(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ package app.ehrenamtskarte.backend.helper
import app.ehrenamtskarte.backend.cards.database.CardEntity
import app.ehrenamtskarte.backend.cards.database.Cards
import app.ehrenamtskarte.backend.cards.database.CodeType
import app.ehrenamtskarte.backend.stores.database.AcceptingStoreEntity
import app.ehrenamtskarte.backend.stores.database.AcceptingStores
import app.ehrenamtskarte.backend.stores.database.Addresses
import app.ehrenamtskarte.backend.stores.database.Contacts
import app.ehrenamtskarte.backend.stores.database.PhysicalStores
import app.ehrenamtskarte.backend.userdata.database.UserEntitlements
import app.ehrenamtskarte.backend.userdata.database.UserEntitlementsEntity
import net.postgis.jdbc.geometry.Point
import org.jetbrains.exposed.sql.insert
import org.jetbrains.exposed.sql.insertAndGetId
import org.jetbrains.exposed.sql.transactions.transaction
import java.time.Instant
import java.time.LocalDate
Expand All @@ -16,6 +23,49 @@ import kotlin.random.Random
*/
object TestData {

fun createAcceptingStore(
name: String = "Test store",
description: String? = "100% Ermäßigung\n\n100% discount",
street: String = "Teststr. 10",
postalCode: String = "90408",
location: String = "Nürnberg",
coordinates: Point = Point(),
email: String? = "[email protected]",
website: String? = "https://www.test.de",
telephone: String? = "0911/123456",
projectId: Int = 2,
categoryId: Int = 17
): AcceptingStoreEntity {
return transaction {
val addressId = Addresses.insertAndGetId {
it[Addresses.street] = street
it[Addresses.postalCode] = postalCode
it[Addresses.location] = location
it[Addresses.countryCode] = "de"
}
val contactId = Contacts.insertAndGetId {
it[Contacts.email] = email
it[Contacts.telephone] = telephone
it[Contacts.website] = website
}
val acceptingStoreRow = AcceptingStores.insert {
it[AcceptingStores.name] = name
it[AcceptingStores.description] = description
it[AcceptingStores.contactId] = contactId
it[AcceptingStores.categoryId] = categoryId
it[AcceptingStores.regionId] = null
it[AcceptingStores.projectId] = projectId
}.resultedValues!!.first()
val acceptingStoreEntity = AcceptingStoreEntity.wrapRow(acceptingStoreRow)
PhysicalStores.insert {
it[PhysicalStores.storeId] = acceptingStoreEntity.id.value
it[PhysicalStores.addressId] = addressId
it[PhysicalStores.coordinates] = coordinates
}
acceptingStoreEntity
}
}

fun createUserEntitlements(
userHash: String,
startDate: LocalDate = LocalDate.now().minusDays(1L),
Expand Down
Loading