Skip to content

Commit

Permalink
add trick to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbogjoe committed Apr 17, 2018
1 parent 955360c commit 9fe9625
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/test/groovy/joe/TestSpec.groovy
Original file line number Diff line number Diff line change
@@ -1,19 +1,31 @@
package joe

import grails.gorm.transactions.Transactional
import grails.testing.gorm.DataTest
import org.grails.datastore.mapping.core.connections.ConnectionSource
import org.grails.datastore.mapping.simple.SimpleMapDatastore
import spock.lang.AutoCleanup
import spock.lang.Shared
import grails.testing.gorm.DomainUnitTest
import org.springframework.core.convert.converter.Converter
import org.springframework.core.convert.support.ConfigurableConversionService
import spock.lang.Specification

class TestSpec extends Specification implements DataTest {
class TestSpec extends Specification implements DomainUnitTest<Test> {

@Shared
@AutoCleanup
SimpleMapDatastore dataStore = new SimpleMapDatastore([ConnectionSource.DEFAULT, "myDataSource"], Test)
static{
System.setProperty("grails.gorm.connections", "myDataSource")
}

@Override
Closure doWithSpring() {
return {
ConfigurableConversionService conversionService = application.mainContext.getEnvironment().getConversionService()
conversionService.addConverter(new Converter<String, Map>() {
@Override
Map convert(String source) {
source.split(",").collectEntries({
[(it):it]
})
}
})
}
}

void testSave() {
when:
Expand Down

0 comments on commit 9fe9625

Please sign in to comment.