Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/enhance accessor test coverage and helper test coverage #92

Merged
merged 5 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions libs/accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { Colors } from "../deps.ts";

export class DimFileAccessor {
private dimJSON: DimJSON | undefined;
private dimJSON: DimJSON;
constructor(path = DEFAULT_DIM_FILE_PATH) {
try {
Deno.statSync(path);
Expand All @@ -33,9 +33,6 @@ export class DimFileAccessor {
);
}
async addContent(content: Content) {
if (this.dimJSON === undefined) {
return;
}
const contents = this.dimJSON.contents;
const contentIndex = this.dimJSON.contents.findIndex((c) => c.name === content.name);
if (contentIndex !== -1) {
Expand All @@ -50,9 +47,6 @@ export class DimFileAccessor {
});
}
async addContents(contents: Content[]) {
if (this.dimJSON === undefined) {
return;
}
// Override the existing content.
const currentContents = this.dimJSON.contents.filter((c) =>
!contents.map((newContent) => newContent.name).includes(
Expand All @@ -69,9 +63,6 @@ export class DimFileAccessor {
});
}
async removeContent(name: string) {
if (this.dimJSON === undefined) {
return;
}
const contents = this.dimJSON.contents.filter((c) => c.name !== name);
await this.writeToDimFile({
fileVersion: DIM_FILE_VERSION,
Expand All @@ -89,7 +80,7 @@ export class DimFileAccessor {
}

export class DimLockFileAccessor {
private dimLockJSON: DimLockJSON | undefined;
private dimLockJSON: DimLockJSON;
constructor() {
try {
Deno.statSync(DEFAULT_DIM_LOCK_FILE_PATH);
Expand All @@ -108,9 +99,6 @@ export class DimLockFileAccessor {
);
}
async addContent(content: LockContent) {
if (this.dimLockJSON === undefined) {
return;
}
const contents = this.dimLockJSON.contents;
const contentIndex = this.dimLockJSON.contents.findIndex((c) => c.name === content.name);
if (contentIndex !== -1) {
Expand All @@ -125,9 +113,6 @@ export class DimLockFileAccessor {
});
}
async addContents(contents: LockContent[]) {
if (this.dimLockJSON === undefined) {
return;
}
// Override the existing content.
const currentContents = this.dimLockJSON.contents.filter((c) =>
!contents.map((newContent) => newContent.name).includes(
Expand Down
7 changes: 0 additions & 7 deletions tests/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ export const createKyGetStub = (
};

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 });
}
Expand Down