()
| 162 | let projectDir: string; |
| 163 | |
| 164 | async function setupTestProject(): Promise<void> { |
| 165 | const npmCacheDir = tmpDirFixture.createNewTmpDir(); |
| 166 | const packageJsonPath = path.join(projectDir, "package.json"); |
| 167 | |
| 168 | await getProcessResult( |
| 169 | execFile(nodePath, [cliEntryPointPath, "init", projectDir, DEFAULT_DATABASE, DEFAULT_LOCATION]) |
| 170 | ); |
| 171 | |
| 172 | const workflowSettingsPath = path.join(projectDir, "workflow_settings.yaml"); |
| 173 | const workflowSettings = dataform.WorkflowSettings.create( |
| 174 | loadYaml(fs.readFileSync(workflowSettingsPath, "utf8")) |
| 175 | ); |
| 176 | delete workflowSettings.dataformCoreVersion; |
| 177 | fs.writeFileSync(workflowSettingsPath, dumpYaml(workflowSettings)); |
| 178 | |
| 179 | fs.writeFileSync( |
| 180 | packageJsonPath, |
| 181 | `{ |
| 182 | "dependencies":{ |
| 183 | "@dataform/core": "${version}" |
| 184 | } |
| 185 | }` |
| 186 | ); |
| 187 | await getProcessResult( |
| 188 | execFile(npmPath, [ |
| 189 | "install", |
| 190 | "--prefix", |
| 191 | projectDir, |
| 192 | "--cache", |
| 193 | npmCacheDir, |
| 194 | corePackageTarPath |
| 195 | ]) |
| 196 | ); |
| 197 | |
| 198 | const assertionFilePath = path.join(projectDir, "definitions", "test_assertion.sqlx"); |
| 199 | fs.ensureFileSync(assertionFilePath); |
| 200 | fs.writeFileSync( |
| 201 | assertionFilePath, |
| 202 | ` |
| 203 | config { type: "assertion" } |
| 204 | SELECT 1 WHERE FALSE |
| 205 | ` |
| 206 | ); |
| 207 | |
| 208 | const tableFilePath = path.join(projectDir, "definitions", "example_table.sqlx"); |
| 209 | fs.ensureFileSync(tableFilePath); |
| 210 | fs.writeFileSync( |
| 211 | tableFilePath, |
| 212 | ` |
| 213 | config { |
| 214 | type: "table", |
| 215 | assertions: { |
| 216 | uniqueKey: ["id"] |
| 217 | } |
| 218 | } |
| 219 | SELECT 1 as id |
| 220 | ` |
| 221 | ); |
no test coverage detected