Skip to content

Commit e730cbe

Browse files
committed
Improve test file logic and cleanup in StableConfigSourceTest class
1 parent 7049d36 commit e730cbe

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

internal-api/src/test/groovy/datadog/trace/bootstrap/config/provider/StableConfigSourceTest.groovy

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,17 @@ class StableConfigSourceTest extends DDSpecification {
3030
}
3131

3232
def "test empty file"() {
33-
when:
33+
given:
3434
Path filePath = Files.createTempFile("testFile_", ".yaml")
35-
then:
36-
if (filePath == null) {
37-
throw new AssertionError("Failed to create: " + filePath)
38-
}
3935

4036
when:
4137
StableConfigSource config = new StableConfigSource(filePath.toString(), ConfigOrigin.LOCAL_STABLE_CONFIG)
4238
then:
4339
config.getKeys().size() == 0
4440
config.getConfigId() == null
41+
42+
cleanup:
43+
Files.delete(filePath)
4544
}
4645

4746
def "test file invalid format"() {
@@ -60,6 +59,8 @@ class StableConfigSourceTest extends DDSpecification {
6059
then:
6160
stableCfg.getConfigId() == null
6261
stableCfg.getKeys().size() == 0
62+
63+
cleanup:
6364
Files.delete(filePath)
6465

6566
where:
@@ -69,12 +70,8 @@ class StableConfigSourceTest extends DDSpecification {
6970
}
7071

7172
def "test file valid format"() {
72-
when:
73+
given:
7374
Path filePath = Files.createTempFile("testFile_", ".yaml")
74-
then:
75-
if (filePath == null) {
76-
throw new AssertionError("Failed to create: " + filePath)
77-
}
7875

7976
when:
8077
StableConfig stableConfigYaml = new StableConfig(configId, defaultConfigs)
@@ -104,6 +101,8 @@ class StableConfigSourceTest extends DDSpecification {
104101
!cfgKeys.contains(keyString)
105102
}
106103
}
104+
105+
cleanup:
107106
Files.delete(filePath)
108107

109108
where:
@@ -114,7 +113,7 @@ class StableConfigSourceTest extends DDSpecification {
114113

115114
def "test parse invalid logs mapping errors"() {
116115
given:
117-
Logger logbackLogger = (Logger) LoggerFactory.getLogger(datadog.trace.bootstrap.config.provider.StableConfigSource)
116+
Logger logbackLogger = (Logger) LoggerFactory.getLogger(StableConfigSource)
118117
def listAppender = new ListAppender<ILoggingEvent>()
119118
listAppender.start()
120119
logbackLogger.addAppender(listAppender)

0 commit comments

Comments
 (0)