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.
Merge branch 'n400-rename_handle_var_to_alias'
- Loading branch information
Showing
24 changed files
with
154 additions
and
135 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
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 { handle } 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 handle( | ||
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 handle(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 handle(registerWithUser(adminClient, '[email protected]', 'testtest'), 'Register with User') | ||
const res = await handle(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 handle(registerWithUser(adminClient, '[email protected]', 'testtest'), 'Register with User') | ||
const res2 = await handle(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 handle(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 handle(createFweet(loggedInClient, 'Tweet user 1 #tag1', ['tag1']), 'Creating Fweet 1') | ||
await handle(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
Oops, something went wrong.