Skip to content
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
28 changes: 28 additions & 0 deletions .github/workflows/hono_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: hono_test

on:
push:
paths:
- 'server/hono/**'
- '.github/workflows/hono_test.yaml'
pull_request:
paths:
- 'server/hono/**'
- '.github/workflows/hono_test.yaml'

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1

- name: Install dependencies
run: bun install

- name: Run tests
run: bun test
working-directory: server/hono
8 changes: 8 additions & 0 deletions server/hono/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
# Serve Blog Contents to View

## Tests

Run unit tests with:

```bash
bun test
```
3 changes: 2 additions & 1 deletion server/hono/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"dev": "wrangler dev src/index.ts",
"deploy": "wrangler deploy --minify src/index.ts",
"lint": "biome check --write ./"
"lint": "biome check --write ./",
"test": "bun test"
},
"dependencies": {
"@octokit/rest": "^21.0.0",
Expand Down
26 changes: 26 additions & 0 deletions server/hono/src/di/container.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { describe, expect, it } from "bun:test";
import { DIContainer } from "./container";

class Foo {
constructor(public value: number) {}
}

class Bar {
constructor(public value: string) {}
}

describe("DIContainer", () => {
it("register stores an instance", () => {
const container = new DIContainer<{ foo: Foo }>();
container.register("foo", Foo, 123);
const instance = container.get("foo");
expect(instance).toBeInstanceOf(Foo);
expect(instance.value).toBe(123);
expect(container.get("foo")).toBe(instance);
});

it("get throws when dependency is not registered", () => {
const container = new DIContainer<{ bar: Bar }>();
expect(() => container.get("bar")).toThrow();
});
});
Loading