Skip to content

Commit

Permalink
Update tests to account for different session management #934
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed May 13, 2024
1 parent de3e52c commit f86a80e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/test/groovy/au/org/ala/ecodata/ProjectServiceSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -770,13 +770,19 @@ class ProjectServiceSpec extends MongoSpec implements ServiceUnitTest<ProjectSer
Project project = new Project(projectId: '345', name: "Project 345", isMERIT: true, hubId:"12345")
project.save(flush: true, failOnError: true)
Map dataSet = [name: 'Test Data Set', description: 'Test Description', dataSetId:'d1']
Project actual
Project actual2
Project actual3
when:
Map resp = service.updateDataSet(project.projectId, dataSet)
Project.withNewSession {
actual = Project.findByProjectId(project.projectId)
}
then:
resp.status == 'ok'
Project actual = Project.findByProjectId(project.projectId)
actual.projectId == project.projectId
actual.name == project.name
actual.isMERIT == project.isMERIT
Expand All @@ -786,23 +792,29 @@ class ProjectServiceSpec extends MongoSpec implements ServiceUnitTest<ProjectSer
when:
Map dataSet2 = [name: 'Test Data Set 2', description: 'Test Description 2', dataSetId:'d2']
resp = service.updateDataSet(project.projectId, dataSet2)
Project.withNewSession {
actual2 = Project.findByProjectId(project.projectId)
}
then:
resp.status == 'ok'
Project actual2 = Project.findByProjectId(project.projectId)
actual2.projectId == project.projectId
actual2.name == project.name
actual2.isMERIT == project.isMERIT
actual2.hubId == project.hubId
actual2.custom.dataSets == [dataSet, dataSet2]
when:
dataSet.name = dataSet.name + " - Updated"
dataSet2.name = dataSet2.name + " - Updated"
resp = service.updateDataSet(project.projectId, dataSet2)
Project.withNewSession {
actual3 = Project.findByProjectId(project.projectId)
}
then:
resp.status == 'ok'
Project actual3 = Project.findByProjectId(project.projectId)
actual3.projectId == project.projectId
actual3.name == project.name
actual3.isMERIT == project.isMERIT
Expand Down Expand Up @@ -886,8 +898,6 @@ class ProjectServiceSpec extends MongoSpec implements ServiceUnitTest<ProjectSer
project2.custom.dataSets.find { it.dataSetId == 'd' + i } != null
}
}
}

0 comments on commit f86a80e

Please sign in to comment.