Skip to content

Commit

Permalink
Updated tests and README
Browse files Browse the repository at this point in the history
  • Loading branch information
julienmalard committed Jan 20, 2024
1 parent eeb46be commit ea6ad94
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: orbit-db-feed tests
name: feed-db tests
on:
push:
branches:
Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# orbit-db-feed
# @orbitdb/feed-db
Feed database type for orbit-db.

[![orbit-db-feed tests](https://github.com/orbitdb/feed/actions/workflows/run-test.yml/badge.svg?branch=main)](https://github.com/orbitdb/feed/actions/workflows/run-test.yml)
[![feed-db tests](https://github.com/orbitdb/feed/actions/workflows/run-test.yml/badge.svg?branch=main)](https://github.com/orbitdb/feed/actions/workflows/run-test.yml)
[![codecov](https://codecov.io/gh/orbitdb/feed/graph/badge.svg?token=7OZK4BJDej)](https://codecov.io/gh/orbitdb/feed)

## Installation
Expand All @@ -13,6 +13,11 @@ $ pnpm add @constl/orbit-db-feed

## Examples
```ts
import { createOrbit } from "@orbitdb/core";
import { registerFeed } from "@orbitdb/feed-db";

// Register database type. IMPORTANT - must call before creating orbit instance !
registerFeed();
const db = await orbit.open({ type: "feed" });

await db.add({ a: 1, b: "c" });
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@orbitdb/feed",
"name": "@orbitdb/feed-db",
"version": "1.0.0",
"description": "Feed database type for orbit-db.",
"author": "Julien Jean Malard-Adam",
Expand Down Expand Up @@ -53,7 +53,8 @@
"rimraf": "^5.0.5",
"ts-patch": "^3.1.2",
"typescript": "^5.3.3",
"typescript-transform-paths": "^3.4.6"
"typescript-transform-paths": "^3.4.6",
"wherearewe": "^2.0.1"
},
"jest": {
"transform": {
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions test/feed.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { type Helia } from "helia";
import { rimraf } from "rimraf";

import { Identities, Identity, KeyStore, KeyStoreType } from "@orbitdb/core";
import Feed, { FeedDatabaseType } from "@/feed.js";
import { DBElements } from "@/types.js";
import { createTestHelia } from "./config.js";
import { Identities, Identity, KeyStore, KeyStoreType } from "@orbitdb/core";
import { isBrowser } from "wherearewe";
import { expect } from "aegir/chai";
import { DBElements } from "@/types.js";

const rimrafImport = import("rimraf");

const keysPath = "./testkeys";

Expand All @@ -19,7 +21,7 @@ describe("Feed Database", () => {
const databaseId = "feed-AAA";

before(async () => {
ipfs = await createTestHelia({ directory: "./ipfs1" });
ipfs = await createTestHelia();

keystore = await KeyStore({ path: keysPath });
identities = await Identities({ keystore });
Expand All @@ -35,9 +37,12 @@ describe("Feed Database", () => {
await keystore.close();
}

await rimraf(keysPath);
await rimraf("./orbitdb");
await rimraf("./ipfs1");
if (!isBrowser) {
const { rimraf } = await rimrafImport;
await rimraf(keysPath);
await rimraf("./orbitdb");
await rimraf("./ipfsOKV");
}
});

describe("Creating a Feed database", () => {
Expand Down

0 comments on commit ea6ad94

Please sign in to comment.