Skip to content
This repository has been archived by the owner on Apr 13, 2021. It is now read-only.

Commit

Permalink
fix: point remote to localhost + error updates
Browse files Browse the repository at this point in the history
Signed-off-by: Carson Farmer <carson.farmer@gmail.com>
  • Loading branch information
carsonfarmer committed Oct 22, 2020
1 parent b631450 commit 6b04605
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/remote/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ export class Remote {

// Blast thru provided collection names...
for (const collectionName of collections) {
// Check that table exists locally...
this.storage.table(collectionName);
// Filter changes by collection
const filtered = localChanges.where("name").equals(collectionName);
if ((await filtered.count()) < 1) {
Expand Down
17 changes: 8 additions & 9 deletions src/remote/remote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { grpc } from "@improbable-eng/grpc-web";
import { Where } from "@textile/threads-client";

const databaseName = "remote";
const serviceHost = "http://localhost:6007";

describe("remote", function () {
// Default Dog interface to work with types
Expand Down Expand Up @@ -81,6 +82,7 @@ describe("remote", function () {
beforeEach(async function () {
// Need to authorize before running any tests...
// But we _could_ cache token if we had one from before...
remote.set({ serviceHost });
await remote.authorize(privateKey);
});

Expand Down Expand Up @@ -154,15 +156,11 @@ describe("remote", function () {
expect(id1).to.not.be.undefined;
expect(ThreadID.fromString(id1).toString()).to.equal(id1);
// Should throw here because we're trying to use an existing db id
try {
// Clear cached id just to be sure we're pulling from the db
remote.id = undefined;
// Leave off id to default to existing id (stored in db)
await remote.initialize(); // Leave off id
throw shouldHaveThrown;
} catch (err) {
expect(err).to.equal(Errors.ThreadExists);
}
// Clear cached id just to be sure we're pulling from the db
remote.id = undefined;
// Leave off id to default to existing id (stored in db)
await remote.initialize(); // Leave off id

// Try with new random one, this isn't a good idea in practice, but is
// allowed because we want to be able to migrate etc in the future
// Application logic should be used to prevent this bad behavior for now
Expand Down Expand Up @@ -231,6 +229,7 @@ describe("remote", function () {
before(async function () {
// Need to authorize before running any tests...
// But we _could_ cache token if we had one from before...
remote.set({ serviceHost });
await remote.authorize(privateKey);
});

Expand Down

0 comments on commit 6b04605

Please sign in to comment.