Files
openide/platform/configuration-store-impl/testSrc/LiveTemplateSchemeTest.kt
Roman Shevchenko 62b8e6ba80 Cleanup (reducing bit rot in configuration store tests)
GitOrigin-RevId: 03722206ff4c9cb60cff154059f1f14227d9da7d
2024-01-19 17:09:55 +00:00

44 lines
1.8 KiB
Kotlin

// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.configurationStore
import com.intellij.codeInsight.template.impl.TemplateSettings
import com.intellij.configurationStore.schemeManager.SchemeManagerFactoryBase
import com.intellij.testFramework.ProjectRule
import com.intellij.testFramework.rules.InMemoryFsRule
import kotlinx.coroutines.runBlocking
import org.assertj.core.api.Assertions.assertThat
import org.junit.ClassRule
import org.junit.Rule
import org.junit.Test
import kotlin.io.path.createParentDirectories
import kotlin.io.path.readText
import kotlin.io.path.writeText
class LiveTemplateSchemeTest {
companion object {
@JvmField @ClassRule val projectRule = ProjectRule()
}
@JvmField @Rule val fsRule = InMemoryFsRule()
// https://youtrack.jetbrains.com/issue/IDEA-155623#comment=27-1721029
@Test fun `do not remove unknown context`() {
val schemeFile = fsRule.fs.getPath("templates/Groovy.xml")
val schemeManagerFactory = SchemeManagerFactoryBase.TestSchemeManagerFactory(fsRule.fs.getPath(""))
@Suppress("SpellCheckingInspection") val schemeData = """
<templateSet group="Groovy">
<template name="serr" value="System.err.println(&quot;$\END$&quot;)dwed" description="Prints a string to System.errwefwe" toReformat="true" toShortenFQNames="true" deactivated="true">
<context>
<option name="GROOVY_STATEMENT" value="false" />
<option name="__DO_NOT_DELETE_ME__" value="true" />
</context>
</template>
</templateSet>""".trimIndent()
schemeFile.createParentDirectories().writeText(schemeData)
TemplateSettings(schemeManagerFactory)
runBlocking { schemeManagerFactory.save() }
assertThat(schemeFile.readText()).isEqualTo(schemeData)
}
}