|
17 | 17 | * limitations under the License.
|
18 | 18 | */
|
19 | 19 |
|
| 20 | +import { int } from '../src' |
20 | 21 | import {
|
21 | 22 | ServerInfo,
|
22 | 23 | Notification,
|
23 | 24 | NotificationSeverityLevel,
|
24 | 25 | NotificationCategory,
|
25 | 26 | notificationSeverityLevel,
|
26 |
| - notificationCategory |
| 27 | + notificationCategory, |
| 28 | + ProfiledPlan, |
| 29 | + QueryStatistics, |
| 30 | + Stats |
27 | 31 | } from '../src/result-summary'
|
28 | 32 |
|
| 33 | +import fc from 'fast-check' |
| 34 | + |
29 | 35 | describe('ServerInfo', () => {
|
30 | 36 | it.each([
|
31 | 37 | [
|
@@ -158,6 +164,203 @@ describe('notificationCategory', () => {
|
158 | 164 | })
|
159 | 165 | })
|
160 | 166 |
|
| 167 | +describe('ProfilePlan', () => { |
| 168 | + describe.each([ |
| 169 | + 'dbHits', |
| 170 | + 'rows', |
| 171 | + 'pageCacheMisses', |
| 172 | + 'pageCacheHits', |
| 173 | + 'pageCacheHitRatio', |
| 174 | + 'time' |
| 175 | + ])('.%s', (field: keyof ProfiledPlan) => { |
| 176 | + it('should handle return arbitrary integer as it is', () => { |
| 177 | + return fc.assert( |
| 178 | + fc.property( |
| 179 | + fc.integer(), |
| 180 | + value => { |
| 181 | + const rawProfilePlan = { |
| 182 | + [field]: value |
| 183 | + } |
| 184 | + |
| 185 | + const profilePlan = new ProfiledPlan(rawProfilePlan) |
| 186 | + |
| 187 | + return profilePlan[field] === value |
| 188 | + } |
| 189 | + ) |
| 190 | + ) |
| 191 | + }) |
| 192 | + |
| 193 | + it('should handle Integer with maxSafeInteger', () => { |
| 194 | + return fc.assert( |
| 195 | + fc.property( |
| 196 | + fc.maxSafeInteger().map(value => [int(value), value]), |
| 197 | + ([value, expectedValue]) => { |
| 198 | + const rawProfilePlan = { |
| 199 | + [field]: value |
| 200 | + } |
| 201 | + |
| 202 | + const profilePlan = new ProfiledPlan(rawProfilePlan) |
| 203 | + |
| 204 | + return profilePlan[field] === expectedValue |
| 205 | + } |
| 206 | + ) |
| 207 | + ) |
| 208 | + }) |
| 209 | + |
| 210 | + it('should handle Integer with arbitrary integer', () => { |
| 211 | + return fc.assert( |
| 212 | + fc.property( |
| 213 | + fc.integer().map(value => [int(value), value]), |
| 214 | + ([value, expectedValue]) => { |
| 215 | + const rawProfilePlan = { |
| 216 | + [field]: value |
| 217 | + } |
| 218 | + |
| 219 | + const profilePlan = new ProfiledPlan(rawProfilePlan) |
| 220 | + |
| 221 | + return profilePlan[field] === expectedValue |
| 222 | + } |
| 223 | + ) |
| 224 | + ) |
| 225 | + }) |
| 226 | + |
| 227 | + it('should handle BigInt with maxSafeInteger', () => { |
| 228 | + return fc.assert( |
| 229 | + fc.property( |
| 230 | + fc.maxSafeInteger().map(value => [BigInt(value), value]), |
| 231 | + ([value, expectedValue]) => { |
| 232 | + const rawProfilePlan = { |
| 233 | + [field]: value |
| 234 | + } |
| 235 | + |
| 236 | + const profilePlan = new ProfiledPlan(rawProfilePlan) |
| 237 | + |
| 238 | + return profilePlan[field] === expectedValue |
| 239 | + } |
| 240 | + ) |
| 241 | + ) |
| 242 | + }) |
| 243 | + |
| 244 | + it('should handle Integer with arbitrary integer', () => { |
| 245 | + return fc.assert( |
| 246 | + fc.property( |
| 247 | + fc.integer().map(value => [BigInt(value), value]), |
| 248 | + ([value, expectedValue]) => { |
| 249 | + const rawProfilePlan = { |
| 250 | + [field]: value |
| 251 | + } |
| 252 | + |
| 253 | + const profilePlan = new ProfiledPlan(rawProfilePlan) |
| 254 | + |
| 255 | + return profilePlan[field] === expectedValue |
| 256 | + } |
| 257 | + ) |
| 258 | + ) |
| 259 | + }) |
| 260 | + }) |
| 261 | +}) |
| 262 | + |
| 263 | +describe('QueryStatistics', () => { |
| 264 | + describe.each([ |
| 265 | + ['nodesCreated', 'nodes-created'], |
| 266 | + ['nodesDeleted', 'nodes-deleted'], |
| 267 | + ['relationshipsCreated', 'relationships-created'], |
| 268 | + ['relationshipsDeleted', 'relationships-deleted'], |
| 269 | + ['propertiesSet', 'properties-set'], |
| 270 | + ['labelsAdded', 'labels-added'], |
| 271 | + ['labelsRemoved', 'labels-removed'], |
| 272 | + ['indexesAdded', 'indexes-added'], |
| 273 | + ['indexesRemoved', 'indexes-removed'], |
| 274 | + ['constraintsAdded', 'constraints-added'], |
| 275 | + ['constraintsRemoved', 'constraints-removed'] |
| 276 | + ])('.updates().%s', (field: keyof Stats, rawField: string) => { |
| 277 | + it('should handle return arbitrary integer as it is', () => { |
| 278 | + return fc.assert( |
| 279 | + fc.property( |
| 280 | + fc.integer(), |
| 281 | + value => { |
| 282 | + const stats = { |
| 283 | + [rawField]: value |
| 284 | + } |
| 285 | + |
| 286 | + const queryStatistics = new QueryStatistics(stats) |
| 287 | + |
| 288 | + return queryStatistics.updates()[field] === value |
| 289 | + } |
| 290 | + ) |
| 291 | + ) |
| 292 | + }) |
| 293 | + |
| 294 | + it('should handle Integer with maxSafeInteger', () => { |
| 295 | + return fc.assert( |
| 296 | + fc.property( |
| 297 | + fc.maxSafeInteger().map(value => [int(value), value]), |
| 298 | + ([value, expectedValue]) => { |
| 299 | + const stats = { |
| 300 | + [rawField]: value |
| 301 | + } |
| 302 | + |
| 303 | + const queryStatistics = new QueryStatistics(stats) |
| 304 | + |
| 305 | + return queryStatistics.updates()[field] === expectedValue |
| 306 | + } |
| 307 | + ) |
| 308 | + ) |
| 309 | + }) |
| 310 | + |
| 311 | + it('should handle Integer with arbitrary integer', () => { |
| 312 | + return fc.assert( |
| 313 | + fc.property( |
| 314 | + fc.integer().map(value => [int(value), value]), |
| 315 | + ([value, expectedValue]) => { |
| 316 | + const stats = { |
| 317 | + [rawField]: value |
| 318 | + } |
| 319 | + |
| 320 | + const queryStatistics = new QueryStatistics(stats) |
| 321 | + |
| 322 | + return queryStatistics.updates()[field] === expectedValue |
| 323 | + } |
| 324 | + ) |
| 325 | + ) |
| 326 | + }) |
| 327 | + |
| 328 | + it('should handle BigInt with maxSafeInteger', () => { |
| 329 | + return fc.assert( |
| 330 | + fc.property( |
| 331 | + fc.maxSafeInteger().map(value => [BigInt(value), value]), |
| 332 | + ([value, expectedValue]) => { |
| 333 | + const stats = { |
| 334 | + [rawField]: value |
| 335 | + } |
| 336 | + |
| 337 | + const queryStatistics = new QueryStatistics(stats) |
| 338 | + |
| 339 | + return queryStatistics.updates()[field] === expectedValue |
| 340 | + } |
| 341 | + ) |
| 342 | + ) |
| 343 | + }) |
| 344 | + |
| 345 | + it('should handle Integer with arbitrary integer', () => { |
| 346 | + return fc.assert( |
| 347 | + fc.property( |
| 348 | + fc.integer().map(value => [BigInt(value), value]), |
| 349 | + ([value, expectedValue]) => { |
| 350 | + const stats = { |
| 351 | + [rawField]: value |
| 352 | + } |
| 353 | + |
| 354 | + const queryStatistics = new QueryStatistics(stats) |
| 355 | + |
| 356 | + return queryStatistics.updates()[field] === expectedValue |
| 357 | + } |
| 358 | + ) |
| 359 | + ) |
| 360 | + }) |
| 361 | + }) |
| 362 | +}) |
| 363 | + |
161 | 364 | function getValidSeverityLevels (): NotificationSeverityLevel[] {
|
162 | 365 | return [
|
163 | 366 | 'WARNING',
|
|
0 commit comments