Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yevhen Ivantsov committed Nov 23, 2023
1 parent 81a3fdf commit 67c6d2f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/charts/bitbucket/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{{- if eq .Values.database.driver nil }}
"dbType": "UNKNOWN",
{{- else }}
{{- $databaseTypeMap := dict "postgres" "POSTGRES" "mssql" "MSSQL" "sqlserver" "SQLSERVER" "oracle" "ORACLE" "mysql" "MYSQL" }}
{{- $databaseTypeMap := dict "postgres" "POSTGRES" "sqlserver" "MSSQL" "oracle" "ORACLE" "mysql" "MYSQL" }}
{{- $dbTypeInValues := .Values.database.driver }}
{{- $dbType := "UNKNOWN" | quote }}
{{- range $key, $value := $databaseTypeMap }}
Expand Down
27 changes: 18 additions & 9 deletions src/test/java/test/HelmValuesAndAnalyticsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,23 @@ void analytics_json_booleans(Product product) throws Exception {
@ParameterizedTest
@EnumSource(value = Product.class, names = {"bamboo_agent", "crowd"}, mode = EnumSource.Mode.EXCLUDE)
void analytics_json_db_type(Product product) throws Exception {
Map<String, String> databaseConfigurations = Map.of(
"postgres72", "org.postgresql.Driver",
"mssql01", "com.microsoft.mssql.jdbc.mssql",
"sqlserver11", "com.microsoft.sqlserver.jdbc.SQLSDriver",
"oracle10", "oracle.jdbc.driver.OracleDriver",
"mysql7", "com.mysql.cj.jdbc.Driver"
);
List<String> normalizedDatabaseTypes = List.of("POSTGRES", "MSSQL", "SQLSERVER", "ORACLE", "MYSQL");
Map<String, String> databaseConfigurations;
if (product == Product.bitbucket) {
databaseConfigurations = Map.of(
"postgres72", "org.postgresql.Driver",
"sqlserver11", "com.microsoft.sqlserver.jdbc.SQLSDriver",
"oracle10", "oracle.jdbc.driver.OracleDriver",
"mysql7", "com.mysql.cj.jdbc.Driver"
);
} else {
databaseConfigurations = Map.of(
"postgres72", "org.postgresql.Driver",
"mssql01", "com.microsoft.mssql.jdbc.mssql",
"oracle10", "oracle.jdbc.driver.OracleDriver",
"mysql7", "com.mysql.cj.jdbc.Driver"
);
}
List<String> normalizedDatabaseTypes = List.of("POSTGRES", "MSSQL", "ORACLE", "MYSQL");
for (Map.Entry<String, String> entry : databaseConfigurations.entrySet()) {
String databaseType = entry.getKey();
String databaseDriver = entry.getValue();
Expand All @@ -189,7 +198,7 @@ void analytics_json_db_type(Product product) throws Exception {
String analyticsJson = resources.get(Kind.ConfigMap, product.getHelmReleaseName() + "-helm-values").getConfigMapData().get("analytics.json").asText();
ObjectMapper objectMapper = new ObjectMapper();
AnalyticsData analyticsData = objectMapper.readValue(analyticsJson, AnalyticsData.class);
assertTrue(normalizedDatabaseTypes.contains(analyticsData.getDbType().toUpperCase()));
assertTrue(normalizedDatabaseTypes.contains(analyticsData.getDbType()));
}
}

Expand Down

0 comments on commit 67c6d2f

Please sign in to comment.