-
Notifications
You must be signed in to change notification settings - Fork 819
/
OSUtilTest.java
38 lines (32 loc) · 1.31 KB
/
OSUtilTest.java
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
/*
* Copyright (c) 2021, PostgreSQL Global Development Group
* See the LICENSE file in the project root for more information.
*/
package org.postgresql.util;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
import uk.org.webcompere.systemstubs.properties.SystemProperties;
import uk.org.webcompere.systemstubs.resource.Resources;
import java.io.File;
@ExtendWith(SystemStubsExtension.class)
class OSUtilTest {
@Test
void getUserConfigRootDirectory() throws Exception {
// windows
Resources.with(new EnvironmentVariables("APPDATA", "C:\\Users\\realuser\\AppData\\Roaming"),
new SystemProperties("os.name", "Windows 10")).execute(() -> {
String result = OSUtil.getUserConfigRootDirectory();
assertEquals("C:\\Users\\realuser\\AppData\\Roaming" + File.separator + "postgresql", result);
}
);
// linux
Resources.with(new SystemProperties("os.name", "Linux", "user.home", "/home/realuser")).execute(() -> {
String result = OSUtil.getUserConfigRootDirectory();
assertEquals("/home/realuser", result);
}
);
}
}