blob: 3cb08f5f2b6416d643ec86e320042b486e931f30 (
plain) (
blame)
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.hosted.plugin;
import com.yahoo.config.provision.InstanceName;
import com.yahoo.config.provision.zone.ZoneId;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import static ai.vespa.hosted.plugin.EffectiveServicesMojo.effectiveServices;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* @author jonmv
* @author olaa
*/
@DisplayName("Effective services are correctly generated")
class EffectiveServicesMojoTest {
private final File servicesFile = new File("src/test/resources/effective-services/services.xml");
@Test
@DisplayName("when zone matches environment-only directive")
void devServices() throws Exception {
assertEquals(Files.readString(Paths.get("src/test/resources/effective-services/dev.xml")),
effectiveServices(servicesFile, ZoneId.from("dev", "us-east-3"), InstanceName.defaultName()));
}
@Test
@DisplayName("when zone matches region-and-environment directive")
void prodUsEast3() throws Exception {
assertEquals(Files.readString(Paths.get("src/test/resources/effective-services/prod_us-east-3.xml")),
effectiveServices(servicesFile, ZoneId.from("prod", "us-east-3"), InstanceName.defaultName()));
}
@Test
@DisplayName("when zone doesn't match any directives")
void prodUsWest1Services() throws Exception {
assertEquals(Files.readString(Paths.get("src/test/resources/effective-services/prod_us-west-1.xml")),
effectiveServices(servicesFile, ZoneId.from("prod", "us-west-1"), InstanceName.defaultName()));
}
}
|