Skip to content

Commit

Permalink
Release v0.1.2 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
5ouma authored Jun 17, 2024
2 parents ad32909 + 5164f9a commit 47f43ab
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ flowchart LR
end
feature1 & feature2 & feature3 -- Squash Merge --> dev
dev -- Rebase Merge --> main
dev -- Merge --> main
```

<br />
Expand Down
7 changes: 0 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ close #

<br />

### ✔︎ Checklists

- [ ] This Pull Request introduces a new feature.
- [ ] This Pull Request fixes a bug.

<br />

### 🔄 Type of the Change

- [ ] 🎉 Feature
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deps-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:

steps:
- name: 🚚 Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: dev

- name: 🦕 Update Dependencies
uses: hasundue/molt-action@v1-rc
uses: hasundue/molt-action@c7e98c50ac87758ba0d1242091990e374784ad79 # v1.0.0-rc.4
with:
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
base: dev
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:

steps:
- name: 🚚 Checkout Repository
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6

- name: 🦕 Setup Deno
uses: denoland/setup-deno@v1
uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba # v1.1.4
with:
deno-version: v1.x

Expand All @@ -41,6 +41,6 @@ jobs:
run: deno check ./**/*.ts

- name: ☂️ Upload Coverage
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
41 changes: 21 additions & 20 deletions test/libs/content_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,31 @@ import { STATUS_CODE } from "@std/http/status";
import { getContent } from "../../src/libs/content.ts";
import { exportRepo, testRef, testRepo, unknownRepo } from "../utils.ts";

Deno.test("Get Content", async <R extends string>() => {
Deno.test("Get Content", async <R extends string>(t: Deno.TestContext) => {
const ctx: RouterContext<R> = testing.createMockContext();
exportRepo(testRepo);
await getContent(ctx);

assertEquals(ctx.response.status, STATUS_CODE.OK);
});
await t.step("normal", async () => {
exportRepo(testRepo);
await getContent(ctx);

Deno.test("Get Content (With ref)", async <R extends string>() => {
const ctx: RouterContext<R> = testing.createMockContext();
exportRepo(testRepo);
await getContent(ctx, testRef);
assertEquals(ctx.response.status, STATUS_CODE.OK);
});

assertEquals(ctx.response.status, STATUS_CODE.OK);
});
await t.step("with ref", async () => {
exportRepo(testRepo);
await getContent(ctx, testRef);

Deno.test("Get Content (Not found)", async <R extends string>() => {
const ctx: RouterContext<R> = testing.createMockContext();
exportRepo(unknownRepo);
await getContent(ctx);
assertEquals(ctx.response.status, STATUS_CODE.OK);
});

await t.step("not found", async () => {
exportRepo(unknownRepo);
await getContent(ctx);

assertEquals(ctx.response.status, STATUS_CODE.NotFound);
assertStringIncludes(
ctx.response.body!.toString(),
`⚠️ ${STATUS_CODE.NotFound}:`,
);
assertEquals(ctx.response.status, STATUS_CODE.NotFound);
assertStringIncludes(
ctx.response.body!.toString(),
`⚠️ ${STATUS_CODE.NotFound}:`,
);
});
});
28 changes: 15 additions & 13 deletions test/libs/env_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ import { assertEquals } from "@std/assert";
import { getRepository } from "../../src/libs/env.ts";
import { clearRepo, exportRepo, testRepo } from "../utils.ts";

Deno.test("Get Repository Env", () => {
exportRepo(testRepo);
const repository = getRepository();
Deno.test("Get Repository Env", async (t: Deno.TestContext) => {
await t.step("Normal", () => {
exportRepo(testRepo);
const repository = getRepository();

assertEquals(repository.owner, testRepo.owner);
assertEquals(repository.name, testRepo.name);
assertEquals(repository.path, testRepo.path);
});
assertEquals(repository.owner, testRepo.owner);
assertEquals(repository.name, testRepo.name);
assertEquals(repository.path, testRepo.path);
});

Deno.test("Get Repository Env (Not set)", () => {
clearRepo();
const repository = getRepository();
await t.step("Not set", () => {
clearRepo();
const repository = getRepository();

assertEquals(repository.owner, "");
assertEquals(repository.name, "");
assertEquals(repository.path, "");
assertEquals(repository.owner, "");
assertEquals(repository.name, "");
assertEquals(repository.path, "");
});
});
35 changes: 18 additions & 17 deletions test/libs/redirect_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@ import { UserAgent } from "@std/http/user-agent";
import { redirect } from "../../src/libs/redirect.ts";
import { exportRepo, testRef, testRepo } from "../utils.ts";

Deno.test("Redirect Detection", <R extends string>() => {
Deno.test("Redirect Detection", async <R extends string>(t: Deno.TestContext) => {
const ctx: RouterContext<R> = testing.createMockContext();
exportRepo(testRepo);
redirect(ctx, new UserAgent("Chrome/1.2.3"));

assertEquals(ctx.response.status, STATUS_CODE.PermanentRedirect);
assertEquals(
ctx.response.headers.get("location"),
`https://github.com/${testRepo.owner}/${testRepo.name}/blob/master/${testRepo.path}`,
);
});
await t.step("normal", () => {
redirect(ctx, new UserAgent("Chrome/1.2.3"));

Deno.test("Redirect Detection (With ref)", <R extends string>() => {
const ctx: RouterContext<R> = testing.createMockContext();
exportRepo(testRepo);
redirect(ctx, new UserAgent("Chrome/1.2.3"), testRef);
assertEquals(ctx.response.status, STATUS_CODE.PermanentRedirect);
assertEquals(
ctx.response.headers.get("location"),
`https://github.com/${testRepo.owner}/${testRepo.name}/blob/master/${testRepo.path}`,
);
});

await t.step("with ref", () => {
redirect(ctx, new UserAgent("Chrome/1.2.3"), testRef);

assertEquals(ctx.response.status, STATUS_CODE.PermanentRedirect);
assertEquals(
ctx.response.headers.get("location"),
`https://github.com/${testRepo.owner}/${testRepo.name}/blob/${testRef}/${testRepo.path}`,
);
assertEquals(ctx.response.status, STATUS_CODE.PermanentRedirect);
assertEquals(
ctx.response.headers.get("location"),
`https://github.com/${testRepo.owner}/${testRepo.name}/blob/${testRef}/${testRepo.path}`,
);
});
});
34 changes: 18 additions & 16 deletions test/router_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,26 @@ import { STATUS_CODE } from "@std/http/status";
import { router } from "../src/router.ts";
import { exportRepo, testRef, testRepo } from "./utils.ts";

Deno.test("Serve (/)", async <R extends string>() => {
const ctx: RouterContext<R> = testing.createMockContext({
method: "GET",
path: "/",
Deno.test("Serve", async <R extends string>(t: Deno.TestContext) => {
await t.step("/", async () => {
const ctx: RouterContext<R> = testing.createMockContext({
method: "GET",
path: "/",
});
exportRepo(testRepo);
await router.routes()(ctx, () => Promise.resolve());

assertEquals(ctx.response.status, STATUS_CODE.OK);
});
exportRepo(testRepo);
await router.routes()(ctx, () => Promise.resolve());

assertEquals(ctx.response.status, STATUS_CODE.OK);
});
await t.step("/:ref", async () => {
const ctx: RouterContext<R> = testing.createMockContext({
method: "GET",
path: `/${testRef}`,
});
exportRepo(testRepo);
await router.routes()(ctx, () => Promise.resolve());

Deno.test("Serve (/:ref)", async <R extends string>() => {
const ctx: RouterContext<R> = testing.createMockContext({
method: "GET",
path: `/${testRef}`,
assertEquals(ctx.response.status, STATUS_CODE.OK);
});
exportRepo(testRepo);
await router.routes()(ctx, () => Promise.resolve());

assertEquals(ctx.response.status, STATUS_CODE.OK);
});

0 comments on commit 47f43ab

Please sign in to comment.