|
16 | 16 |
|
17 | 17 | package com.twosigma.webtau.cfg |
18 | 18 |
|
| 19 | +import com.twosigma.webtau.report.ReportGenerators |
| 20 | +import com.twosigma.webtau.report.ReportTestEntries |
19 | 21 | import org.junit.Test |
20 | 22 |
|
| 23 | +import static com.twosigma.webtau.Ddjt.code |
| 24 | +import static com.twosigma.webtau.Ddjt.throwException |
| 25 | + |
21 | 26 | class WebTauGroovyFileConfigHandlerTest { |
22 | 27 | @Test |
23 | 28 | void "should use default environment values when env is not specified"() { |
24 | 29 | def cfg = createConfig() |
| 30 | + handle(cfg) |
25 | 31 |
|
26 | | - def handler = new WebTauGroovyFileConfigHandler() |
27 | | - handler.onAfterCreate(cfg) |
28 | | - |
29 | | - cfg.baseUrl.should == "http://localhost:8180" |
| 32 | + cfg.baseUrl.should == 'http://localhost:8180' |
30 | 33 | } |
31 | 34 |
|
32 | 35 | @Test |
33 | 36 | void "should use environment specific values when env is specified"() { |
34 | 37 | def cfg = createConfig() |
35 | | - cfg.envConfigValue.set("test", "dev") |
| 38 | + cfg.envConfigValue.set('test', 'dev') |
36 | 39 |
|
| 40 | + handle(cfg) |
| 41 | + |
| 42 | + cfg.baseUrl.should == 'http://dev.host:8080' |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + void "should let specify custom reporter"() { |
| 47 | + def cfg = createConfig() |
| 48 | + cfg.envConfigValue.set('test', 'prod') |
| 49 | + |
| 50 | + handle(cfg) |
| 51 | + |
| 52 | + cfg.reportPath.toFile().deleteOnExit() |
| 53 | + |
| 54 | + // prod report throws exception on purpose |
| 55 | + code { |
| 56 | + ReportGenerators.generate(new ReportTestEntries()) |
| 57 | + } should throwException('report issue 0') |
| 58 | + } |
| 59 | + |
| 60 | + private static void handle(WebTauConfig cfg) { |
37 | 61 | def handler = new WebTauGroovyFileConfigHandler() |
38 | 62 | handler.onAfterCreate(cfg) |
39 | | - |
40 | | - cfg.baseUrl.should == "http://dev.host:8080" |
41 | 63 | } |
42 | 64 |
|
43 | 65 | private static WebTauConfig createConfig() { |
44 | 66 | def cfg = new WebTauConfig() |
45 | | - cfg.configFileName.set("test", "src/test/resources/webtau.cfg") |
| 67 | + cfg.configFileName.set('test', 'src/test/resources/webtau.cfg') |
46 | 68 |
|
47 | 69 | return cfg |
48 | 70 | } |
|
0 commit comments