[Test] Add ability to remove default directives in test configuration

This commit is contained in:
Dmitriy Novozhilov
2020-12-30 12:04:34 +03:00
committed by TeamCityServer
parent e3c7bd5f85
commit e6fd74f368
@@ -16,6 +16,10 @@ class RegisteredDirectivesBuilder {
simpleDirectives += this
}
operator fun SimpleDirective.unaryMinus() {
simpleDirectives.remove(this)
}
infix fun StringDirective.with(value: String) {
with(listOf(value))
}
@@ -24,6 +28,10 @@ class RegisteredDirectivesBuilder {
stringDirectives.putWithExistsCheck(this, values)
}
operator fun StringDirective.unaryMinus() {
stringDirectives.remove(this)
}
infix fun <T : Any> ValueDirective<T>.with(value: T) {
with(listOf(value))
}
@@ -32,6 +40,10 @@ class RegisteredDirectivesBuilder {
valueDirectives.putWithExistsCheck(this, values)
}
operator fun ValueDirective<*>.unaryMinus() {
valueDirectives.remove(this)
}
private fun <K : Directive, V> MutableMap<K, V>.putWithExistsCheck(key: K, value: V) {
val alreadyRegistered = put(key, value)
if (alreadyRegistered != null) {