Skip to content

Commit

Permalink
Do not erase database on deployment (#104)
Browse files Browse the repository at this point in the history
* Do not erase database on deployment

* Enhance tests
  • Loading branch information
QubitPi authored Nov 29, 2023
1 parent 404e2d7 commit 19bab82
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private static Properties getDefaultDbConfigs() {
final Properties dbProperties = new Properties();

dbProperties.put("hibernate.show_sql", "true");
dbProperties.put("hibernate.hbm2ddl.auto", "create");
dbProperties.put("hibernate.hbm2ddl.auto", "update");
dbProperties.put("hibernate.dialect", JPA_DATASTORE_CONFIG.dbDialect());
dbProperties.put("hibernate.current_session_context_class", "thread");
dbProperties.put("hibernate.jdbc.use_scrollable_resultset", "true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import com.qubitpi.ws.jersey.template.models.Book

import org.apache.http.HttpStatus

import groovy.json.JsonBuilder
import io.restassured.RestAssured
import io.restassured.response.Response
import jakarta.validation.constraints.NotNull
Expand Down Expand Up @@ -429,9 +430,11 @@ abstract class AbstractITSpec extends Specification {

def "GraphQL API can sort and paginate (effectively fetching 1 record with some min/max attribute)"() {
given: "3 entities are inserted into the database"
createBook(new Book(id: 1, title: "Pride & Prejudice"))
createBook(new Book(id: 2, title: "Effective Java"))
createBook(new Book(id: 3, title: "Critiques of Pure Reason"))
createBook(new Book(title: "Pride & Prejudice"))
createBook(new Book(title: "Effective Java"))
final String maxBookId = createBook(new Book(title: "Critiques of Pure Reason"))
.jsonPath()
.get("data.book.edges[0].node.id")
expect: "sorting by ID in descending order and paginating to get the firsts result returns Kant's work"
RestAssured
Expand Down Expand Up @@ -461,23 +464,25 @@ abstract class AbstractITSpec extends Specification {
)
.when().post().then()
.statusCode(200)
.body("", equalTo(
data: [
book: [
edges:[[
node: [
id: "3",
title:"Critiques of Pure Reason"
.body(equalTo(
new JsonBuilder(
data: [
book: [
edges:[[
node: [
id: "${maxBookId}",
title:"Critiques of Pure Reason"
]
]],
pageInfo: [
totalRecords: 3,
startCursor: "0",
endCursor: "1",
hasNextPage:true
]
]],
pageInfo: [
totalRecords: 3,
startCursor: "0",
endCursor: "1",
hasNextPage:true
]
]
] as HashMap
).toString()
))
}
Expand Down

0 comments on commit 19bab82

Please sign in to comment.