|
| 1 | +import { assertValidatorAcceptsAndDoesNotWarn, assertValidatorRejects } from './helpers'; |
| 2 | + |
| 3 | +describe('flexSearchPerformanceParams in @rootEntity', () => { |
| 4 | + it('accepts omitting it', () => { |
| 5 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 6 | + type Stuff @rootEntity( |
| 7 | + flexSearch: true |
| 8 | + ) { |
| 9 | + foo: String @flexSearch |
| 10 | + } |
| 11 | + `); |
| 12 | + }); |
| 13 | + it('accepts it empty', () => { |
| 14 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 15 | + type Stuff @rootEntity( |
| 16 | + flexSearch: true |
| 17 | + flexSearchPerformanceParams: {} |
| 18 | + ) { |
| 19 | + foo: String @flexSearch |
| 20 | + } |
| 21 | + `); |
| 22 | + }); |
| 23 | + |
| 24 | + describe('commitIntervalMsec', () => { |
| 25 | + it('accepts it being null', () => { |
| 26 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 27 | + type Stuff @rootEntity( |
| 28 | + flexSearch: true |
| 29 | + flexSearchPerformanceParams: { |
| 30 | + commitIntervalMsec: null |
| 31 | + } |
| 32 | + ) { |
| 33 | + foo: String @flexSearch |
| 34 | + } |
| 35 | + `); |
| 36 | + }); |
| 37 | + |
| 38 | + it('accepts 100', () => { |
| 39 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 40 | + type Stuff @rootEntity( |
| 41 | + flexSearch: true |
| 42 | + flexSearchPerformanceParams: { |
| 43 | + commitIntervalMsec: 100 |
| 44 | + } |
| 45 | + ) { |
| 46 | + foo: String @flexSearch |
| 47 | + } |
| 48 | + `); |
| 49 | + }); |
| 50 | + |
| 51 | + it('accepts 5000', () => { |
| 52 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 53 | + type Stuff @rootEntity( |
| 54 | + flexSearch: true |
| 55 | + flexSearchPerformanceParams: { |
| 56 | + commitIntervalMsec: 5000 |
| 57 | + } |
| 58 | + ) { |
| 59 | + foo: String @flexSearch |
| 60 | + } |
| 61 | + `); |
| 62 | + }); |
| 63 | + |
| 64 | + it('rejects 50', () => { |
| 65 | + assertValidatorRejects( |
| 66 | + ` |
| 67 | + type Stuff @rootEntity( |
| 68 | + flexSearch: true |
| 69 | + flexSearchPerformanceParams: { |
| 70 | + commitIntervalMsec: 50 |
| 71 | + } |
| 72 | + ) { |
| 73 | + foo: String @flexSearch |
| 74 | + } |
| 75 | + `, |
| 76 | + 'Cannot be less than 100.', |
| 77 | + ); |
| 78 | + }); |
| 79 | + |
| 80 | + it('rejects -1', () => { |
| 81 | + assertValidatorRejects( |
| 82 | + ` |
| 83 | + type Stuff @rootEntity( |
| 84 | + flexSearch: true |
| 85 | + flexSearchPerformanceParams: { |
| 86 | + commitIntervalMsec: -1 |
| 87 | + } |
| 88 | + ) { |
| 89 | + foo: String @flexSearch |
| 90 | + } |
| 91 | + `, |
| 92 | + 'Cannot be less than 100.', |
| 93 | + ); |
| 94 | + }); |
| 95 | + |
| 96 | + it('rejects 123.4', () => { |
| 97 | + assertValidatorRejects( |
| 98 | + ` |
| 99 | + type Stuff @rootEntity( |
| 100 | + flexSearch: true |
| 101 | + flexSearchPerformanceParams: { |
| 102 | + commitIntervalMsec: 123.4 |
| 103 | + } |
| 104 | + ) { |
| 105 | + foo: String @flexSearch |
| 106 | + } |
| 107 | + `, |
| 108 | + 'Int cannot represent non-integer value: 123.4', |
| 109 | + ); |
| 110 | + }); |
| 111 | + }); |
| 112 | + |
| 113 | + describe('consolidationIntervalMsec', () => { |
| 114 | + it('accepts it being null', () => { |
| 115 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 116 | + type Stuff @rootEntity( |
| 117 | + flexSearch: true |
| 118 | + flexSearchPerformanceParams: { |
| 119 | + consolidationIntervalMsec: null |
| 120 | + } |
| 121 | + ) { |
| 122 | + foo: String @flexSearch |
| 123 | + } |
| 124 | + `); |
| 125 | + }); |
| 126 | + |
| 127 | + it('accepts 100', () => { |
| 128 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 129 | + type Stuff @rootEntity( |
| 130 | + flexSearch: true |
| 131 | + flexSearchPerformanceParams: { |
| 132 | + consolidationIntervalMsec: 100 |
| 133 | + } |
| 134 | + ) { |
| 135 | + foo: String @flexSearch |
| 136 | + } |
| 137 | + `); |
| 138 | + }); |
| 139 | + |
| 140 | + it('accepts 5000', () => { |
| 141 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 142 | + type Stuff @rootEntity( |
| 143 | + flexSearch: true |
| 144 | + flexSearchPerformanceParams: { |
| 145 | + consolidationIntervalMsec: 5000 |
| 146 | + } |
| 147 | + ) { |
| 148 | + foo: String @flexSearch |
| 149 | + } |
| 150 | + `); |
| 151 | + }); |
| 152 | + |
| 153 | + it('rejects 50', () => { |
| 154 | + assertValidatorRejects( |
| 155 | + ` |
| 156 | + type Stuff @rootEntity( |
| 157 | + flexSearch: true |
| 158 | + flexSearchPerformanceParams: { |
| 159 | + consolidationIntervalMsec: 50 |
| 160 | + } |
| 161 | + ) { |
| 162 | + foo: String @flexSearch |
| 163 | + } |
| 164 | + `, |
| 165 | + 'Cannot be less than 100.', |
| 166 | + ); |
| 167 | + }); |
| 168 | + |
| 169 | + it('rejects -1', () => { |
| 170 | + assertValidatorRejects( |
| 171 | + ` |
| 172 | + type Stuff @rootEntity( |
| 173 | + flexSearch: true |
| 174 | + flexSearchPerformanceParams: { |
| 175 | + consolidationIntervalMsec: -1 |
| 176 | + } |
| 177 | + ) { |
| 178 | + foo: String @flexSearch |
| 179 | + } |
| 180 | + `, |
| 181 | + 'Cannot be less than 100.', |
| 182 | + ); |
| 183 | + }); |
| 184 | + |
| 185 | + it('rejects 123.4', () => { |
| 186 | + assertValidatorRejects( |
| 187 | + ` |
| 188 | + type Stuff @rootEntity( |
| 189 | + flexSearch: true |
| 190 | + flexSearchPerformanceParams: { |
| 191 | + consolidationIntervalMsec: 123.4 |
| 192 | + } |
| 193 | + ) { |
| 194 | + foo: String @flexSearch |
| 195 | + } |
| 196 | + `, |
| 197 | + 'Int cannot represent non-integer value: 123.4', |
| 198 | + ); |
| 199 | + }); |
| 200 | + }); |
| 201 | + |
| 202 | + describe('cleanupIntervalStep', () => { |
| 203 | + it('accepts it being null', () => { |
| 204 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 205 | + type Stuff @rootEntity( |
| 206 | + flexSearch: true |
| 207 | + flexSearchPerformanceParams: { |
| 208 | + cleanupIntervalStep: null |
| 209 | + } |
| 210 | + ) { |
| 211 | + foo: String @flexSearch |
| 212 | + } |
| 213 | + `); |
| 214 | + }); |
| 215 | + |
| 216 | + it('accepts 0', () => { |
| 217 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 218 | + type Stuff @rootEntity( |
| 219 | + flexSearch: true |
| 220 | + flexSearchPerformanceParams: { |
| 221 | + cleanupIntervalStep: 0 |
| 222 | + } |
| 223 | + ) { |
| 224 | + foo: String @flexSearch |
| 225 | + } |
| 226 | + `); |
| 227 | + }); |
| 228 | + |
| 229 | + it('accepts 5', () => { |
| 230 | + assertValidatorAcceptsAndDoesNotWarn(` |
| 231 | + type Stuff @rootEntity( |
| 232 | + flexSearch: true |
| 233 | + flexSearchPerformanceParams: { |
| 234 | + cleanupIntervalStep: 5 |
| 235 | + } |
| 236 | + ) { |
| 237 | + foo: String @flexSearch |
| 238 | + } |
| 239 | + `); |
| 240 | + }); |
| 241 | + |
| 242 | + it('rejects -1', () => { |
| 243 | + assertValidatorRejects( |
| 244 | + ` |
| 245 | + type Stuff @rootEntity( |
| 246 | + flexSearch: true |
| 247 | + flexSearchPerformanceParams: { |
| 248 | + cleanupIntervalStep: -1 |
| 249 | + } |
| 250 | + ) { |
| 251 | + foo: String @flexSearch |
| 252 | + } |
| 253 | + `, |
| 254 | + 'Cannot be negative.', |
| 255 | + ); |
| 256 | + }); |
| 257 | + |
| 258 | + it('rejects 123.4', () => { |
| 259 | + assertValidatorRejects( |
| 260 | + ` |
| 261 | + type Stuff @rootEntity( |
| 262 | + flexSearch: true |
| 263 | + flexSearchPerformanceParams: { |
| 264 | + cleanupIntervalStep: 123.4 |
| 265 | + } |
| 266 | + ) { |
| 267 | + foo: String @flexSearch |
| 268 | + } |
| 269 | + `, |
| 270 | + 'Int cannot represent non-integer value: 123.4', |
| 271 | + ); |
| 272 | + }); |
| 273 | + }); |
| 274 | +}); |
0 commit comments