forked from fauna-labs/fwitter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brecht De Rooms
committed
Apr 27, 2020
1 parent
c5fad0a
commit b122473
Showing
12 changed files
with
89 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import faunadb from 'faunadb' | |
|
||
import { setupDatabase, deleteAndCreateDatabase } from '../setup/database' | ||
|
||
import { alias } from './../helpers/errors' | ||
import { handlePromiseError } from './../helpers/errors' | ||
import { registerWithUser, login } from './auth' | ||
import { getFweets, createFweet, createFweetWithoutUDF } from './fweets' | ||
import { follow } from './followers' | ||
|
@@ -29,34 +29,40 @@ beforeAll(async () => { | |
secret: process.env.REACT_APP_TEST__ADMIN_KEY | ||
}) | ||
// Create the admin client for the new database to bootstrap things | ||
const secret = await alias( | ||
const secret = await handlePromiseError( | ||
deleteAndCreateDatabase(adminClientParentDb, 'fweets-spec'), | ||
'Creating temporary test database' | ||
) | ||
adminClient = new faunadb.Client({ | ||
secret: secret | ||
}) | ||
// Setup the database for this test. | ||
await alias(setupDatabase(adminClient), 'Setup Database') | ||
await handlePromiseError(setupDatabase(adminClient), 'Setup Database') | ||
|
||
// Create a client with a login key (getting privileges from 'memberships' in roles) | ||
// We create a user directly as well | ||
await alias(registerWithUser(adminClient, '[email protected]', 'testtest'), 'Register with User') | ||
const res = await alias(login(adminClient, '[email protected]', 'testtest'), 'Login') | ||
await handlePromiseError(registerWithUser(adminClient, '[email protected]', 'testtest'), 'Register with User') | ||
const res = await handlePromiseError(login(adminClient, '[email protected]', 'testtest'), 'Login') | ||
loggedInClient = new faunadb.Client({ secret: res.secret }) | ||
user1Ref = res.user.ref | ||
|
||
await alias(registerWithUser(adminClient, '[email protected]', 'testtest'), 'Register with User') | ||
const res2 = await alias(login(adminClient, '[email protected]', 'testtest'), 'Login') | ||
await handlePromiseError(registerWithUser(adminClient, '[email protected]', 'testtest'), 'Register with User') | ||
const res2 = await handlePromiseError(login(adminClient, '[email protected]', 'testtest'), 'Login') | ||
loggedInClient2 = new faunadb.Client({ secret: res2.secret }) | ||
|
||
// Create a client with the bootstrap key (assuming the bootstrap role) | ||
const key = await alias(adminClient.query(CreateKey({ role: Role('keyrole_calludfs') })), 'Creating Bootstrap Key') | ||
const key = await handlePromiseError( | ||
adminClient.query(CreateKey({ role: Role('keyrole_calludfs') })), | ||
'Creating Bootstrap Key' | ||
) | ||
bootstrapClient = new faunadb.Client({ secret: key.secret }) | ||
|
||
user2Ref = res2.user.ref | ||
await alias(createFweet(loggedInClient, 'Tweet user 1 #tag1', ['tag1']), 'Creating Fweet 1') | ||
await alias(createFweet(loggedInClient2, 'Tweet user 2 #tag2 #tag3', ['tag2', 'tag3']), 'Creating Fweet 2') | ||
await handlePromiseError(createFweet(loggedInClient, 'Tweet user 1 #tag1', ['tag1']), 'Creating Fweet 1') | ||
await handlePromiseError( | ||
createFweet(loggedInClient2, 'Tweet user 2 #tag2 #tag3', ['tag2', 'tag3']), | ||
'Creating Fweet 2' | ||
) | ||
|
||
return | ||
// Set up a resource that we should only be able to access after logging in. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters