Skip to content

Commit

Permalink
#1039 Disabling all custom settings before each test (backport to dep…
Browse files Browse the repository at this point in the history
…recated classes)
  • Loading branch information
dcoraboeuf committed Nov 1, 2022
1 parent 831f6d5 commit 57e468d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package net.nemerosa.ontrack.extension.general

import net.nemerosa.ontrack.graphql.AbstractQLKTITJUnit4Support
import net.nemerosa.ontrack.graphql.AbstractQLKTITSupport
import net.nemerosa.ontrack.model.structure.ProjectEntity
import net.nemerosa.ontrack.model.structure.nameValues
import net.nemerosa.ontrack.model.structure.typeName
import net.nemerosa.ontrack.model.structure.varName
import org.junit.Test
import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
import kotlin.test.assertNotNull
import kotlin.test.assertNull

class MetaInfoPropertyMutationProviderIT : AbstractQLKTITJUnit4Support() {
class MetaInfoPropertyMutationProviderIT : AbstractQLKTITSupport() {

@Test
fun `Setting the meta info property at different levels`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import net.nemerosa.ontrack.model.settings.PredefinedPromotionLevelService
import net.nemerosa.ontrack.model.settings.PredefinedValidationStampService
import net.nemerosa.ontrack.model.structure.*
import net.nemerosa.ontrack.model.support.OntrackConfigProperties
import net.nemerosa.ontrack.model.support.SettingsRepository
import net.nemerosa.ontrack.test.TestUtils
import net.nemerosa.ontrack.test.TestUtils.uid
import org.junit.Before
import org.junit.jupiter.api.BeforeEach
import org.springframework.beans.factory.annotation.Autowired
import java.time.LocalDateTime
import kotlin.reflect.KClass
Expand All @@ -39,6 +42,9 @@ abstract class AbstractDSLTestJUnit4Support : AbstractServiceTestJUnit4Support()
@Autowired
protected lateinit var settingsService: CachedSettingsService

@Autowired
protected lateinit var settingsRepository: SettingsRepository

@Autowired
protected lateinit var predefinedPromotionLevelService: PredefinedPromotionLevelService

Expand All @@ -53,6 +59,15 @@ abstract class AbstractDSLTestJUnit4Support : AbstractServiceTestJUnit4Support()
protected final inline fun <reified T : GlobalFunction, R> asUserWith(noinline code: () -> R): R =
asUser().with(T::class.java).call(code)

/**
* Removing all settings before any test
*/
@Before
fun clearSettings() {
settingsRepository.clear()
cachedSettingsService.invalidateAll()
}

/**
* Kotlin friendly
*/
Expand Down

0 comments on commit 57e468d

Please sign in to comment.