-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #197 - added DatabaseService enum for integration
- Loading branch information
1 parent
d2f01fb
commit 3712cbb
Showing
5 changed files
with
56 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
client/src/test/java/me/retrodaredevil/solarthing/integration/DatabaseService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package me.retrodaredevil.solarthing.integration; | ||
|
||
public enum DatabaseService { | ||
COUCHDB("couchdb"), | ||
; | ||
|
||
private final String serviceName; | ||
DatabaseService(String serviceName) { | ||
this.serviceName = serviceName; | ||
} | ||
|
||
public String getHost() { | ||
String key = serviceName + ".host"; | ||
String host = System.getProperty(key); | ||
if (host == null) { | ||
throw new IllegalStateException("System property does not exist for key: " + key); | ||
} | ||
return host; | ||
} | ||
public int getPort() { | ||
// The gradle compose plugin sets system properties for the services defined in the docker compose file: | ||
// https://github.com/avast/gradle-docker-compose-plugin | ||
String key = serviceName + ".tcp.5984"; | ||
String portString = System.getProperty(key); | ||
if (portString == null) { | ||
throw new IllegalStateException("System property does not exist for key: " + key); | ||
} | ||
return Integer.parseInt(portString); | ||
} | ||
public static DatabaseService[] couchOnly() { | ||
return new DatabaseService[]{COUCHDB}; | ||
} | ||
public static DatabaseService[] all() { | ||
return values(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ services: | |
- 'COUCHDB_USER=admin' | ||
- 'COUCHDB_PASSWORD=password' | ||
ports: | ||
- '5984:5984' | ||
- '5984' |