Skip to content

Commit

Permalink
feat: TIRS testing
Browse files Browse the repository at this point in the history
Framework set up for allowing testing of TIRS code, either directly or through Job Contexts (With setup to ignore these tests when not using the correct TIRS... this appears to be the only way to run these tests.)
  • Loading branch information
EthanFreestone committed Jun 11, 2024
1 parent 79f388b commit e3e6940
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ abstract class BaseSpec extends HttpSpec {
TitleInstanceResolverService titleInstanceResolverService
@Ignore
def injectedTIRS() {
log.debug("LOGDEBUG INJECTED TIRS CALLED: ${titleInstanceResolverService?.class?.name}")
titleInstanceResolverService?.class?.name
}

Expand Down
30 changes: 30 additions & 0 deletions service/src/integration-test/groovy/org/olf/tirs/TIRSSpec.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.olf.tirs

import org.olf.BaseSpec

import spock.lang.Stepwise
import spock.lang.Ignore

import spock.lang.*

import groovy.util.logging.Slf4j

@Slf4j
@Stepwise
abstract class TIRSSpec extends BaseSpec {
// Place to house any shared TIRS testing methods etc
@Ignore
Boolean isWorkSourceTIRS() {
injectedTIRS() == WORK_SOURCE_TIRS
}

@Ignore
Boolean isIdTIRS() {
injectedTIRS() == ID_TIRS
}

@Ignore
Boolean isTitleTIRS() {
injectedTIRS() == TITLE_TIRS
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.olf.tirs

import org.olf.dataimport.internal.PackageContentImpl
import org.olf.kb.TitleInstance

import com.k_int.okapi.OkapiTenantResolver

import grails.gorm.transactions.Transactional
import grails.gorm.multitenancy.Tenants
import grails.testing.mixin.integration.Integration
import grails.web.databinding.DataBindingUtils
import groovy.transform.CompileStatic
import spock.lang.*

@Integration
@Stepwise
class WorkSourceIdentifierTIRSSpec extends TIRSSpec {
// titleInstanceResolverService is injected in baseSpec now

// Test directly
// TODO actually fill this out
void 'Test directly' () {
when: 'Do a thing'
String hw = "Hello world"
then: 'test a thing'
true == true
}

// Test within job runner context (only run when WorkSourceIdTIRS is the chosen TIRS)
// TODO actually fill this out
@Requires({ instance.isWorkSourceTIRS() })
void 'Test in job runner context' () {
when: 'Do a thing 2'
String hw = "Hello world 2"
then: 'test a thing 2'
true == true
}
}

0 comments on commit e3e6940

Please sign in to comment.