IDEA-CR-15780 do not write default context values
[idea/community.git] / platform / configuration-store-impl / testSrc / TemplateSchemeTest.kt
1 package com.intellij.configurationStore
2
3 import com.intellij.codeInsight.template.impl.TemplateSettings
4 import com.intellij.testFramework.InMemoryFsRule
5 import com.intellij.testFramework.ProjectRule
6 import com.intellij.util.io.readText
7 import com.intellij.util.io.write
8 import org.assertj.core.api.Assertions.assertThat
9 import org.junit.ClassRule
10 import org.junit.Rule
11 import org.junit.Test
12
13 class TemplateSchemeTest {
14   companion object {
15     @JvmField
16     @ClassRule
17     val projectRule = ProjectRule()
18   }
19
20   @JvmField
21   @Rule
22   val fsRule = InMemoryFsRule()
23
24   // https://youtrack.jetbrains.com/issue/IDEA-155623#comment=27-1721029
25   @Test fun `do not remove unknown context`() {
26     val schemeFile = fsRule.fs.getPath("templates/Groovy.xml")
27     val schemeManagerFactory = SchemeManagerFactoryBase.TestSchemeManagerFactory(fsRule.fs.getPath(""))
28     val schemeData = """
29     <templateSet group="Groovy">
30       <template name="serr" value="System.err.println(&quot;$\END$&quot;)dwed" description="Prints a string to System.errwefwe" toReformat="true" toShortenFQNames="true" deactivated="true">
31         <context>
32           <option name="__DO_NOT_DELETE_ME__" value="true" />
33           <option name="GROOVY_STATEMENT" value="false" />
34         </context>
35       </template>
36     </templateSet>""".trimIndent()
37
38     schemeFile.write(schemeData)
39
40     TemplateSettings(schemeManagerFactory)
41     schemeManagerFactory.save()
42     assertThat(schemeFile.readText()).isEqualTo(schemeData)
43   }
44 }