Skip to content

Commit 950fe75

Browse files
Merge pull request #21 from MaximumTrainer/copilot/fix-type-mismatches-between-frontend-backend
Align TableMode and LogLevel enums between frontend and backend
2 parents e1f3836 + dbb638a commit 950fe75

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

backend/src/main/kotlin/com/opendatamask/model/JobLog.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import jakarta.persistence.*
44
import java.time.LocalDateTime
55

66
enum class LogLevel {
7-
INFO, WARN, ERROR
7+
DEBUG, INFO, WARN, ERROR
88
}
99

1010
@Entity

backend/src/main/kotlin/com/opendatamask/model/TableConfiguration.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import jakarta.persistence.*
44
import java.time.LocalDateTime
55

66
enum class TableMode {
7-
PASSTHROUGH, MASK, GENERATE, SUBSET
7+
PASSTHROUGH, MASK, GENERATE, SUBSET, SKIP
88
}
99

1010
@Entity

backend/src/main/kotlin/com/opendatamask/service/JobService.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ class JobService(
123123
addLog(job.id, "Processing ${tableConfigs.size} table(s)", LogLevel.INFO)
124124

125125
for (tableConfig in tableConfigs) {
126+
if (tableConfig.mode == TableMode.SKIP) {
127+
addLog(job.id, "Skipping table: ${tableConfig.tableName}", LogLevel.INFO)
128+
continue
129+
}
126130
addLog(job.id, "Mirroring schema for table: ${tableConfig.tableName}", LogLevel.INFO)
127131
destinationSchemaService.mirrorSchema(
128132
sourceConnector, sourceConn.type,
@@ -194,6 +198,9 @@ class JobService(
194198
val written = destConnector.writeData(tableConfig.tableName, data)
195199
addLog(jobId, "Wrote $written rows to destination ${tableConfig.tableName}", LogLevel.INFO)
196200
}
201+
TableMode.SKIP -> {
202+
// unreachable: SKIP tables are short-circuited in the calling loop
203+
}
197204
}
198205
}
199206

backend/src/test/kotlin/com/opendatamask/model/EnumAlignmentTest.kt

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,37 @@ class EnumAlignmentTest {
2121
}
2222

2323
@Test
24-
fun `WorkspaceRole contains VIEWER`() {
24+
fun `UserRole contains canonical set`() {
25+
val values = UserRole.values().map { it.name }.toSet()
26+
val expected = setOf("ADMIN", "USER", "VIEWER")
27+
assertEquals(expected, values, "UserRole values do not match canonical set")
28+
}
29+
30+
@Test
31+
fun `WorkspaceRole contains canonical set`() {
2532
val values = WorkspaceRole.values().map { it.name }.toSet()
26-
assertTrue(values.contains("VIEWER"), "WorkspaceRole must contain VIEWER")
33+
val expected = setOf("ADMIN", "USER", "VIEWER")
34+
assertEquals(expected, values, "WorkspaceRole values do not match canonical set")
35+
}
36+
37+
@Test
38+
fun `TableMode contains canonical set`() {
39+
val values = TableMode.values().map { it.name }.toSet()
40+
val expected = setOf("PASSTHROUGH", "MASK", "GENERATE", "SUBSET", "SKIP")
41+
assertEquals(expected, values, "TableMode values do not match canonical set")
42+
}
43+
44+
@Test
45+
fun `LogLevel contains canonical set`() {
46+
val values = LogLevel.values().map { it.name }.toSet()
47+
val expected = setOf("DEBUG", "INFO", "WARN", "ERROR")
48+
assertEquals(expected, values, "LogLevel values do not match canonical set")
49+
}
50+
51+
@Test
52+
fun `JobStatus contains canonical set`() {
53+
val values = JobStatus.values().map { it.name }.toSet()
54+
val expected = setOf("PENDING", "RUNNING", "COMPLETED", "FAILED", "CANCELLED")
55+
assertEquals(expected, values, "JobStatus values do not match canonical set")
2756
}
2857
}

0 commit comments

Comments
 (0)