-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Ignore generated files in testing * Add sample test * Add install test * Add init test * Add list test * Add uninstall test * Add update test * Add help test * Remove redundant double quote from eTag * Output colored error message when specify duplicate name * Close subprocess before finish post process * Fix deno lint violation * Improve unit test for InstallAction * Correction of test name * Stub ky.get and use it in some tests * Change of test format * Fix InstallAction test * Fix ListAction test * Fix UninstallAction test * Fix InitAction test * Fix updateAction test * Correction of test name * Delete help test * Correction of Japanese comments. * Temporary commit * Update interactive search test pattern * Change "ky" to "Stub" and Assert added * Correction of test name * Ensure temporary directory and ignore error if does not exist it * Changes to test summaries * Renaming files * Fixing install's assert without specifying the url * Add test data * Rewriting of version and pass * Additional correction of error messages * Minor correction groups * Fix SearchAction test * Remove unnecessary import * Changes to the install.test overview * Assert and Stub modifications. * Changes to the update.test overview * Tests when downloads fail * delete only * Allow blob data to specify stub for ky.get * check xlsx-to-csv * Amendments to xlsx and test summaries. * Corrected location of assert * Change to copyFileSync. * Mock apropriate target to suppress duplicate calling for SearchAction#exexute * Assert only rows parameter when specify number * Cancellation of constants * Changing the location of createEmptyDimJson * Dummy of the date * Organising the Stub * Changes to test summaries * Fix SearchAction test * Remove denoExitStub * Fix actual and expected being reversed * Add unittest for communication error while install in search command * SUse original Deno.exit method to stop execution while testing * Add without keyword test * Add error message to test * Fix install test * Fix SearchAction test * Fix test description * Remove only * Remove whitespace and add blank line * Restore current directory to output coverage report to original place * Fix xckan_site_url and url * Support for unzip testing of darwin os. * Support for unzip test of search on darwin os Co-authored-by: Sheile <sheile1024@gmail.com> Co-authored-by: TakayasuKoura <5574536+TakayasuKoura@users.noreply.github.com>
- Loading branch information
1 parent
1f4247b
commit e3d4108
Showing
16 changed files
with
3,987 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,8 @@ | |
.DS_Store | ||
data_files | ||
dim.json | ||
dim-lock.json | ||
dim-lock.json | ||
|
||
# Test results | ||
tests/coverage | ||
tests/temporary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Stub, stub } from "https://deno.land/std@0.152.0/testing/mock.ts"; | ||
import { resolve } from "https://deno.land/std@0.152.0/path/mod.ts"; | ||
import { ky } from "../deps.ts"; | ||
|
||
const currentDirectory = new URL(".", import.meta.url).pathname; | ||
export const temporaryDirectory = resolve(currentDirectory, "temporary") + "/"; | ||
Deno.mkdirSync(temporaryDirectory, { recursive: true }); | ||
|
||
export const createKyGetStub = ( | ||
body: BodyInit, | ||
options?: ResponseInit, | ||
): Stub => { | ||
const mockedKy = ky.extend({ | ||
hooks: { | ||
beforeRequest: [ | ||
(_request) => { | ||
return new Response(body, options); | ||
}, | ||
], | ||
}, | ||
}); | ||
|
||
return stub(ky, "get", mockedKy.get); | ||
}; | ||
|
||
export const removeTemporaryFiles = () => { | ||
// Skip removing process when temporary directory does not exist | ||
try { | ||
Deno.statSync(temporaryDirectory); | ||
} catch { | ||
return; | ||
} | ||
|
||
for (const path of Deno.readDirSync(temporaryDirectory)) { | ||
Deno.removeSync(temporaryDirectory + path.name, { recursive: true }); | ||
} | ||
}; | ||
|
||
export function fileExists(filePath: string): boolean { | ||
try { | ||
Deno.statSync(filePath); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
|
||
export const createEmptyDimJson = () => { | ||
Deno.writeTextFileSync( | ||
"dim.json", | ||
JSON.stringify({ fileVersion: "1.1", contents: [] }), | ||
); | ||
Deno.writeTextFileSync( | ||
"dim-lock.json", | ||
JSON.stringify({ lockfileVersion: "1.1", contents: [] }), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { assertEquals } from "https://deno.land/std@0.152.0/testing/asserts.ts"; | ||
import { Stub, stub } from "https://deno.land/std@0.152.0/testing/mock.ts"; | ||
import { | ||
afterEach, | ||
beforeEach, | ||
describe, | ||
it, | ||
} from "https://deno.land/std@0.152.0/testing/bdd.ts"; | ||
|
||
import { InitAction } from "../../libs/actions.ts"; | ||
import { removeTemporaryFiles, temporaryDirectory } from "../helper.ts"; | ||
|
||
describe("InitAction", () => { | ||
let consoleLogStub: Stub; | ||
let originalDirectory: string; | ||
|
||
beforeEach(() => { | ||
consoleLogStub = stub(console, "log"); | ||
originalDirectory = Deno.cwd(); | ||
Deno.chdir(temporaryDirectory); | ||
}); | ||
|
||
afterEach(() => { | ||
removeTemporaryFiles(); | ||
consoleLogStub.restore(); | ||
Deno.chdir(originalDirectory); | ||
}); | ||
|
||
it("ensure that empty data directories, dim.json and dim-lock.json are created.", async () => { | ||
await new InitAction().execute(); | ||
|
||
const dataDirectory = Deno.statSync("data_files"); | ||
assertEquals(dataDirectory.isDirectory, true); | ||
|
||
const dimJson = JSON.parse( | ||
Deno.readTextFileSync("dim.json"), | ||
); | ||
assertEquals(dimJson, { fileVersion: "1.1", contents: [] }); | ||
|
||
const dimLockJson = JSON.parse( | ||
Deno.readTextFileSync("dim-lock.json"), | ||
); | ||
assertEquals(dimLockJson, { lockFileVersion: "1.1", contents: [] }); | ||
}); | ||
}); |
Oops, something went wrong.