-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathYamlDeprecatedTest.kt
More file actions
139 lines (106 loc) · 3.05 KB
/
YamlDeprecatedTest.kt
File metadata and controls
139 lines (106 loc) · 3.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
package ftl.args.yml
import com.google.common.truth.Truth.assertThat
import ftl.test.util.FlankTestRunner
import org.junit.Rule
import org.junit.Test
import org.junit.contrib.java.lang.system.SystemOutRule
import org.junit.runner.RunWith
import java.io.StringReader
@RunWith(FlankTestRunner::class)
class YamlDeprecatedTest {
@Rule
@JvmField
val systemOutRule: SystemOutRule = SystemOutRule().enableLog().muteForSuccessfulTests()
@Test
fun `Valid YAML`() {
val input = """
---
gcloud:
app: "a"
test: "b"
flank: {}
""".trimIndent()
val (error, output) = YamlDeprecated.modify(input)
assertThat(error).isFalse()
assertThat(output).isEqualTo(input)
}
@Test
fun `Inserts missing parents`() {
val input = ""
val expected = """
---
gcloud: {}
flank: {}
""".trimIndent()
val (error, output) = YamlDeprecated.modify(input)
assertThat(error).isFalse()
assertThat(output).isEqualTo(expected)
}
@Test
fun `Transform missing Flank object node`() {
// Verify input with null flank ObjectNode is successfully replaced
val input = """
---
gcloud:
project: 0
""".trimIndent()
val expected = """
---
gcloud: {}
flank:
project: 0
""".trimIndent()
val (error, output) = YamlDeprecated.modify(input)
assertThat(error).isFalse()
assertThat(output).isEqualTo(expected)
}
@Test
fun `Old keys renamed to new keys`() {
val input = """
---
gcloud:
project: 0
flaky-test-attempts: 1
flank:
testShards: 1
shardTime: 2
repeatTests: 3
smartFlankGcsPath: 4
disableSharding: 5
""".trimIndent()
val expected = """
---
gcloud:
num-flaky-test-attempts: 1
flank:
project: 0
max-test-shards: 1
shard-time: 2
num-test-runs: 3
smart-flank-gcs-path: 4
disable-sharding: 5
""".trimIndent()
val (error, output) = YamlDeprecated.modify(input)
assertThat(error).isFalse()
assertThat(output).isEqualTo(expected)
}
@Test
fun `repeat-tests is renamed`() {
val input = """
---
gcloud: {}
flank:
repeat-tests: 3
""".trimIndent()
val expected = """
---
gcloud: {}
flank:
num-test-runs: 3
""".trimIndent()
val (error, output) = YamlDeprecated.modify(input)
assertThat(error).isFalse()
assertThat(output).isEqualTo(expected)
}
}
private fun YamlDeprecated.modify(yamlData: String): Pair<Boolean, String> = modify(StringReader(yamlData))