Skip to content

Commit 7a172c8

Browse files
committed
More relative-path improvements
Signed-off-by: Ben Hale <[email protected]>
1 parent 7c85333 commit 7a172c8

File tree

7 files changed

+104
-144
lines changed

7 files changed

+104
-144
lines changed

cloudfoundry-operations/src/test/java/org/cloudfoundry/operations/applications/ApplicationManifestUtilsTest.java

Lines changed: 47 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -48,66 +48,6 @@ public void anchorsAndReferences() throws IOException {
4848
assertThat(actual).isEqualTo(expected);
4949
}
5050

51-
@Test
52-
public void read() throws IOException {
53-
List<ApplicationManifest> expected = Arrays.asList(
54-
ApplicationManifest.builder()
55-
.name("alpha-application-1")
56-
.buildpack("alpha-buildpack")
57-
.command("alpha-command")
58-
.disk(-1)
59-
.healthCheckHttpEndpoint("alpha-health-check-http-endpoint")
60-
.healthCheckType(NONE)
61-
.instances(-1)
62-
.memory(1)
63-
.noRoute(true)
64-
.path(Paths.get("/alpha-path"))
65-
.randomRoute(true)
66-
.route(Route.builder()
67-
.route("alpha-route-1")
68-
.build())
69-
.route(Route.builder()
70-
.route("alpha-route-2")
71-
.build())
72-
.stack("alpha-stack")
73-
.timeout(-1)
74-
.environmentVariable("ALPHA_KEY_1", "alpha-value-1")
75-
.environmentVariable("ALPHA_KEY_2", "alpha-value-2")
76-
.service("alpha-instance-1")
77-
.service("alpha-instance-2")
78-
.build(),
79-
ApplicationManifest.builder()
80-
.name("alpha-application-2")
81-
.buildpack("alpha-buildpack")
82-
.command("alpha-command")
83-
.disk(-1)
84-
.domain("alpha-domain")
85-
.domain("alpha-domains-1")
86-
.domain("alpha-domains-2")
87-
.healthCheckHttpEndpoint("alpha-health-check-http-endpoint")
88-
.healthCheckType(PORT)
89-
.host("alpha-host")
90-
.host("alpha-hosts-1")
91-
.host("alpha-hosts-2")
92-
.instances(-1)
93-
.memory(1024)
94-
.noHostname(true)
95-
.noRoute(true)
96-
.path(Paths.get("c:\\alpha-path"))
97-
.randomRoute(true)
98-
.stack("alpha-stack")
99-
.timeout(-1)
100-
.environmentVariable("ALPHA_KEY_1", "1")
101-
.environmentVariable("ALPHA_KEY_2", "alpha-value-2")
102-
.service("alpha-instance-1")
103-
.service("alpha-instance-2")
104-
.build());
105-
106-
List<ApplicationManifest> actual = ApplicationManifestUtils.read(new ClassPathResource("fixtures/manifest-alpha.yml").getFile().toPath());
107-
108-
assertThat(actual).isEqualTo(expected);
109-
}
110-
11151
@Test
11252
public void readCommon() throws IOException {
11353
List<ApplicationManifest> expected = Arrays.asList(
@@ -324,32 +264,6 @@ public void readInherit() throws IOException {
324264
.service("beta-instance-1")
325265
.service("beta-instance-2")
326266
.build(),
327-
ApplicationManifest.builder()
328-
.name("alpha-application-2")
329-
.buildpack("alpha-buildpack")
330-
.command("alpha-command")
331-
.disk(-1)
332-
.domain("alpha-domain")
333-
.domain("alpha-domains-1")
334-
.domain("alpha-domains-2")
335-
.healthCheckHttpEndpoint("alpha-health-check-http-endpoint")
336-
.healthCheckType(PORT)
337-
.host("alpha-host")
338-
.host("alpha-hosts-1")
339-
.host("alpha-hosts-2")
340-
.instances(-1)
341-
.memory(1024)
342-
.noHostname(true)
343-
.noRoute(true)
344-
.path(Paths.get("c:\\alpha-path"))
345-
.randomRoute(true)
346-
.stack("alpha-stack")
347-
.timeout(-1)
348-
.environmentVariable("ALPHA_KEY_1", "1")
349-
.environmentVariable("ALPHA_KEY_2", "alpha-value-2")
350-
.service("alpha-instance-1")
351-
.service("alpha-instance-2")
352-
.build(),
353267
ApplicationManifest.builder()
354268
.name("beta-application-1")
355269
.buildpack("beta-buildpack")
@@ -460,7 +374,7 @@ public void readNoRoute() throws IOException {
460374

461375
@Test
462376
public void relativePath() throws IOException {
463-
Path root = new ClassPathResource("fixtures/manifest-mike.yml").getFile().toPath();
377+
Path root = new ClassPathResource("fixtures/manifest-november.yml").getFile().toPath();
464378

465379
List<ApplicationManifest> expected = Collections.singletonList(
466380
ApplicationManifest.builder()
@@ -523,23 +437,68 @@ public void testDiskQuotaAndMemoryParsing() throws Exception {
523437
.build()
524438
);
525439

526-
List<ApplicationManifest> actual = ApplicationManifestUtils.read(new ClassPathResource("fixtures/manifest-quota.yml").getFile().toPath());
440+
List<ApplicationManifest> actual = ApplicationManifestUtils.read(new ClassPathResource("fixtures/manifest-mike.yml").getFile().toPath());
527441

528442
assertThat(actual).isEqualTo(expected);
529443
}
530444

445+
@Test
446+
public void unixRead() throws IOException {
447+
assumeTrue(SystemUtils.IS_OS_UNIX);
448+
read("/alpha-path", "fixtures/manifest-alpha-unix.yml");
449+
}
450+
531451
@Test
532452
public void unixWrite() throws IOException {
533453
assumeTrue(SystemUtils.IS_OS_UNIX);
534454
write("/alpha-path", "fixtures/manifest-echo-unix.yml");
535455
}
536456

457+
@Test
458+
public void windowsRead() throws IOException {
459+
assumeTrue(SystemUtils.IS_OS_WINDOWS);
460+
read("c:\\alpha-path", "fixtures/manifest-alpha-windows.yml");
461+
}
462+
537463
@Test
538464
public void windowsWrite() throws IOException {
539465
assumeTrue(SystemUtils.IS_OS_WINDOWS);
540466
write("c:\\alpha-path", "fixtures/manifest-echo-windows.yml");
541467
}
542468

469+
private void read(String path, String expectedManifest) throws IOException {
470+
List<ApplicationManifest> expected = Arrays.asList(
471+
ApplicationManifest.builder()
472+
.name("alpha-application-1")
473+
.buildpack("alpha-buildpack")
474+
.command("alpha-command")
475+
.disk(-1)
476+
.healthCheckHttpEndpoint("alpha-health-check-http-endpoint")
477+
.healthCheckType(NONE)
478+
.instances(-1)
479+
.memory(1)
480+
.noRoute(true)
481+
.path(Paths.get(path))
482+
.randomRoute(true)
483+
.route(Route.builder()
484+
.route("alpha-route-1")
485+
.build())
486+
.route(Route.builder()
487+
.route("alpha-route-2")
488+
.build())
489+
.stack("alpha-stack")
490+
.timeout(-1)
491+
.environmentVariable("ALPHA_KEY_1", "alpha-value-1")
492+
.environmentVariable("ALPHA_KEY_2", "alpha-value-2")
493+
.service("alpha-instance-1")
494+
.service("alpha-instance-2")
495+
.build());
496+
497+
List<ApplicationManifest> actual = ApplicationManifestUtils.read(new ClassPathResource(expectedManifest).getFile().toPath());
498+
499+
assertThat(actual).isEqualTo(expected);
500+
}
501+
543502
private void write(String path, String expectedManifest) throws IOException {
544503
Path out = Files.createTempFile("test-manifest-", ".yml");
545504

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
applications:
3+
- name: alpha-application-1
4+
buildpack: alpha-buildpack
5+
command: alpha-command
6+
disk_quota: -1
7+
health-check-http-endpoint: alpha-health-check-http-endpoint
8+
health-check-type: none
9+
instances: -1
10+
memory: 1M
11+
path: /alpha-path
12+
no-route: true
13+
random-route: true
14+
routes:
15+
- route: alpha-route-1
16+
- route: alpha-route-2
17+
stack: alpha-stack
18+
timeout: -1
19+
env:
20+
ALPHA_KEY_1: alpha-value-1
21+
ALPHA_KEY_2: alpha-value-2
22+
services:
23+
- alpha-instance-1
24+
- alpha-instance-2

cloudfoundry-operations/src/test/resources/fixtures/manifest-alpha.yml renamed to cloudfoundry-operations/src/test/resources/fixtures/manifest-alpha-windows.yml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,6 @@
11
---
22
applications:
33
- name: alpha-application-1
4-
buildpack: alpha-buildpack
5-
command: alpha-command
6-
disk_quota: -1
7-
health-check-http-endpoint: alpha-health-check-http-endpoint
8-
health-check-type: none
9-
instances: -1
10-
memory: 1M
11-
path: /alpha-path
12-
no-route: true
13-
random-route: true
14-
routes:
15-
- route: alpha-route-1
16-
- route: alpha-route-2
17-
stack: alpha-stack
18-
timeout: -1
19-
env:
20-
ALPHA_KEY_1: alpha-value-1
21-
ALPHA_KEY_2: alpha-value-2
22-
services:
23-
- alpha-instance-1
24-
- alpha-instance-2
25-
26-
- name: alpha-application-2
274
buildpack: alpha-buildpack
285
command: alpha-command
296
disk_quota: -1

cloudfoundry-operations/src/test/resources/fixtures/manifest-beta.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
inherit: manifest-alpha.yml
2+
inherit: manifest-alpha-unix.yml
33

44
applications:
55
- name: alpha-application-1
Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
---
22
applications:
3-
- name: alpha-application-1
4-
path: alpha-path
3+
- name: quota-test-1
4+
memory: 1m
5+
disk_quota: 2m
6+
- name: quota-test-2
7+
memory: 3mb
8+
disk_quota: 4mb
9+
- name: quota-test-3
10+
memory: 5M
11+
disk_quota: 6M
12+
- name: quota-test-4
13+
memory: 7MB
14+
disk_quota: 8MB
15+
- name: quota-test-5
16+
memory: 1g
17+
disk_quota: 2g
18+
- name: quota-test-6
19+
memory: 3gb
20+
disk_quota: 4gb
21+
- name: quota-test-7
22+
memory: 5G
23+
disk_quota: 6G
24+
- name: quota-test-8
25+
memory: 7GB
26+
disk_quota: 8GB
27+
- name: quota-test-9
28+
memory: 1234
29+
disk_quota: 5678
30+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
applications:
3+
- name: alpha-application-1
4+
path: alpha-path

cloudfoundry-operations/src/test/resources/fixtures/manifest-quota.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)