|
1 | | -import { mapUrlValue } from "../../../src/common/bqrs-raw-results-mapper"; |
| 1 | +import { |
| 2 | + bqrsToResultSet, |
| 3 | + mapUrlValue, |
| 4 | +} from "../../../src/common/bqrs-raw-results-mapper"; |
| 5 | +import { |
| 6 | + BqrsResultSetSchema, |
| 7 | + DecodedBqrsChunk, |
| 8 | +} from "../../../src/common/bqrs-cli-types"; |
| 9 | +import { ColumnKind } from "../../../src/common/raw-result-types"; |
| 10 | + |
| 11 | +describe("bqrsToResultSet", () => { |
| 12 | + const schema: BqrsResultSetSchema = { |
| 13 | + name: "#select", |
| 14 | + columns: [ |
| 15 | + { |
| 16 | + name: "endpoint", |
| 17 | + kind: "e", |
| 18 | + }, |
| 19 | + { |
| 20 | + kind: "s", |
| 21 | + }, |
| 22 | + { |
| 23 | + kind: "s", |
| 24 | + }, |
| 25 | + { |
| 26 | + kind: "s", |
| 27 | + }, |
| 28 | + { |
| 29 | + kind: "s", |
| 30 | + }, |
| 31 | + { |
| 32 | + name: "supported", |
| 33 | + kind: "b", |
| 34 | + }, |
| 35 | + { |
| 36 | + kind: "s", |
| 37 | + }, |
| 38 | + { |
| 39 | + name: "type", |
| 40 | + kind: "s", |
| 41 | + }, |
| 42 | + ], |
| 43 | + rows: 2, |
| 44 | + }; |
| 45 | + |
| 46 | + const chunk: DecodedBqrsChunk = { |
| 47 | + columns: [ |
| 48 | + { name: "endpoint", kind: "Entity" }, |
| 49 | + { kind: "String" }, |
| 50 | + { kind: "String" }, |
| 51 | + { kind: "String" }, |
| 52 | + { kind: "String" }, |
| 53 | + { name: "supported", kind: "Boolean" }, |
| 54 | + { kind: "String" }, |
| 55 | + { name: "type", kind: "String" }, |
| 56 | + ], |
| 57 | + tuples: [ |
| 58 | + [ |
| 59 | + { |
| 60 | + label: "connect", |
| 61 | + url: { |
| 62 | + uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java", |
| 63 | + startLine: 22, |
| 64 | + startColumn: 19, |
| 65 | + endLine: 22, |
| 66 | + endColumn: 25, |
| 67 | + }, |
| 68 | + }, |
| 69 | + "org.example", |
| 70 | + "HelloController", |
| 71 | + "connect", |
| 72 | + "(String)", |
| 73 | + false, |
| 74 | + "example", |
| 75 | + "", |
| 76 | + ], |
| 77 | + [ |
| 78 | + { |
| 79 | + label: "index", |
| 80 | + url: { |
| 81 | + uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java", |
| 82 | + startLine: 13, |
| 83 | + startColumn: 19, |
| 84 | + endLine: 13, |
| 85 | + endColumn: 23, |
| 86 | + }, |
| 87 | + }, |
| 88 | + "org.example", |
| 89 | + "HelloController", |
| 90 | + "index", |
| 91 | + "(String)", |
| 92 | + true, |
| 93 | + "example", |
| 94 | + "summary", |
| 95 | + ], |
| 96 | + [ |
| 97 | + { |
| 98 | + label: "index", |
| 99 | + url: "file://home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java:15:19:15:23", |
| 100 | + }, |
| 101 | + "org.example", |
| 102 | + "HelloController", |
| 103 | + "index", |
| 104 | + "(String)", |
| 105 | + true, |
| 106 | + "example", |
| 107 | + "summary", |
| 108 | + ], |
| 109 | + ], |
| 110 | + }; |
| 111 | + |
| 112 | + it("creates a result set", () => { |
| 113 | + expect(bqrsToResultSet(schema, chunk)).toEqual({ |
| 114 | + name: "#select", |
| 115 | + totalRowCount: 2, |
| 116 | + columns: [ |
| 117 | + { |
| 118 | + name: "endpoint", |
| 119 | + kind: ColumnKind.Entity, |
| 120 | + }, |
| 121 | + { |
| 122 | + kind: ColumnKind.String, |
| 123 | + }, |
| 124 | + { |
| 125 | + kind: ColumnKind.String, |
| 126 | + }, |
| 127 | + { |
| 128 | + kind: ColumnKind.String, |
| 129 | + }, |
| 130 | + { |
| 131 | + kind: ColumnKind.String, |
| 132 | + }, |
| 133 | + { |
| 134 | + name: "supported", |
| 135 | + kind: ColumnKind.Boolean, |
| 136 | + }, |
| 137 | + { |
| 138 | + kind: ColumnKind.String, |
| 139 | + }, |
| 140 | + { |
| 141 | + name: "type", |
| 142 | + kind: ColumnKind.String, |
| 143 | + }, |
| 144 | + ], |
| 145 | + rows: [ |
| 146 | + [ |
| 147 | + { |
| 148 | + type: "entity", |
| 149 | + value: { |
| 150 | + label: "connect", |
| 151 | + url: { |
| 152 | + type: "lineColumnLocation", |
| 153 | + uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java", |
| 154 | + startLine: 22, |
| 155 | + startColumn: 19, |
| 156 | + endLine: 22, |
| 157 | + endColumn: 25, |
| 158 | + }, |
| 159 | + }, |
| 160 | + }, |
| 161 | + { |
| 162 | + type: "string", |
| 163 | + value: "org.example", |
| 164 | + }, |
| 165 | + { |
| 166 | + type: "string", |
| 167 | + value: "HelloController", |
| 168 | + }, |
| 169 | + { |
| 170 | + type: "string", |
| 171 | + value: "connect", |
| 172 | + }, |
| 173 | + { |
| 174 | + type: "string", |
| 175 | + value: "(String)", |
| 176 | + }, |
| 177 | + { |
| 178 | + type: "boolean", |
| 179 | + value: false, |
| 180 | + }, |
| 181 | + { |
| 182 | + type: "string", |
| 183 | + value: "example", |
| 184 | + }, |
| 185 | + { |
| 186 | + type: "string", |
| 187 | + value: "", |
| 188 | + }, |
| 189 | + ], |
| 190 | + [ |
| 191 | + { |
| 192 | + type: "entity", |
| 193 | + value: { |
| 194 | + label: "index", |
| 195 | + url: { |
| 196 | + type: "lineColumnLocation", |
| 197 | + uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java", |
| 198 | + startLine: 13, |
| 199 | + startColumn: 19, |
| 200 | + endLine: 13, |
| 201 | + endColumn: 23, |
| 202 | + }, |
| 203 | + }, |
| 204 | + }, |
| 205 | + { |
| 206 | + type: "string", |
| 207 | + value: "org.example", |
| 208 | + }, |
| 209 | + { |
| 210 | + type: "string", |
| 211 | + value: "HelloController", |
| 212 | + }, |
| 213 | + { |
| 214 | + type: "string", |
| 215 | + value: "index", |
| 216 | + }, |
| 217 | + { |
| 218 | + type: "string", |
| 219 | + value: "(String)", |
| 220 | + }, |
| 221 | + { |
| 222 | + type: "boolean", |
| 223 | + value: true, |
| 224 | + }, |
| 225 | + { |
| 226 | + type: "string", |
| 227 | + value: "example", |
| 228 | + }, |
| 229 | + { |
| 230 | + type: "string", |
| 231 | + value: "summary", |
| 232 | + }, |
| 233 | + ], |
| 234 | + [ |
| 235 | + { |
| 236 | + type: "entity", |
| 237 | + value: { |
| 238 | + label: "index", |
| 239 | + url: { |
| 240 | + type: "lineColumnLocation", |
| 241 | + uri: "home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java", |
| 242 | + startLine: 15, |
| 243 | + startColumn: 19, |
| 244 | + endLine: 15, |
| 245 | + endColumn: 23, |
| 246 | + }, |
| 247 | + }, |
| 248 | + }, |
| 249 | + { |
| 250 | + type: "string", |
| 251 | + value: "org.example", |
| 252 | + }, |
| 253 | + { |
| 254 | + type: "string", |
| 255 | + value: "HelloController", |
| 256 | + }, |
| 257 | + { |
| 258 | + type: "string", |
| 259 | + value: "index", |
| 260 | + }, |
| 261 | + { |
| 262 | + type: "string", |
| 263 | + value: "(String)", |
| 264 | + }, |
| 265 | + { |
| 266 | + type: "boolean", |
| 267 | + value: true, |
| 268 | + }, |
| 269 | + { |
| 270 | + type: "string", |
| 271 | + value: "example", |
| 272 | + }, |
| 273 | + { |
| 274 | + type: "string", |
| 275 | + value: "summary", |
| 276 | + }, |
| 277 | + ], |
| 278 | + ], |
| 279 | + }); |
| 280 | + }); |
| 281 | +}); |
2 | 282 |
|
3 | 283 | describe("mapUrlValue", () => { |
4 | 284 | it("should detect Windows whole-file locations", () => { |
|
0 commit comments