Commit b826a42
committed
DataConnectCacheDatabaseMigrator.kt, DataConnectCacheDatabaseMigratorUnitTest.kt: Improve user_version error message and add tests
The error message for an invalid `user_version` in `DataConnectCacheDatabaseMigrator` was improved to include the version number in both decimal and hexadecimal formats. This provides more context for debugging.
Additionally, unit tests were added to `DataConnectCacheDatabaseMigratorUnitTest` to verify the behavior of the `user_version` migration. These tests cover setting the `user_version` in a new database, ensuring it remains unchanged if already correct, and verifying that an exception is thrown for invalid versions.
### Changes
* DataConnectCacheDatabaseMigrator.kt:
* Updated `InvalidUserVersionException` to include the `user_version` in both decimal and hexadecimal formats.
* Removed an unnecessary type check when reading the schema version from the database.
* DataConnectCacheDatabaseMigratorUnitTest.kt:
* Added a test to ensure `InvalidUserVersionException` is thrown for invalid `user_version` values and that the error message is correct.
* Added a test to verify that `user_version` is set correctly in a new database.
* Added a test to verify that `user_version` is not changed if it is already correct.1 parent abf53e9 commit b826a42
File tree
2 files changed
+56
-4
lines changed- firebase-dataconnect/src
- main/kotlin/com/google/firebase/dataconnect/sqlite2
- test/kotlin/com/google/firebase/dataconnect/sqlite2
2 files changed
+56
-4
lines changedLines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
| |||
140 | 139 | | |
141 | 140 | | |
142 | 141 | | |
143 | | - | |
144 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
145 | 147 | | |
146 | 148 | | |
147 | 149 | | |
| |||
150 | 152 | | |
151 | 153 | | |
152 | 154 | | |
153 | | - | |
| 155 | + | |
154 | 156 | | |
155 | 157 | | |
156 | 158 | | |
| |||
Lines changed: 50 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
114 | 164 | | |
115 | 165 | | |
116 | 166 | | |
| |||
0 commit comments