-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(gatsby): disable loki stuff without dropping it
- Loading branch information
Showing
10 changed files
with
145 additions
and
143 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
112 changes: 56 additions & 56 deletions
112
packages/gatsby/src/db/loki/__tests__/nodes-query-test.js
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 |
---|---|---|
@@ -1,56 +1,56 @@ | ||
if (process.env.GATSBY_DB_NODES === `loki`) { | ||
const _ = require(`lodash`) | ||
const { GraphQLObjectType } = require(`graphql`) | ||
const { store } = require(`../../../redux`) | ||
const runQuery = require(`../nodes-query`) | ||
const { getNodeTypeCollection } = require(`../nodes`) | ||
const lokiDb = require(`../index`) | ||
|
||
function makeNodes() { | ||
return [ | ||
{ | ||
id: `1`, | ||
internal: { type: `Test` }, | ||
children: [], | ||
foo: `bar`, | ||
}, | ||
] | ||
} | ||
|
||
async function runQueries(nodes, n) { | ||
for (const node of nodes) { | ||
store.dispatch({ type: `CREATE_NODE`, payload: node }) | ||
} | ||
const gqlType = new GraphQLObjectType({ | ||
name: `Test`, | ||
fields: { | ||
foo: { type: `String` }, | ||
}, | ||
}) | ||
const queryArgs = { filter: { foo: { eq: `bar` } } } | ||
const args = { gqlType, queryArgs, nodeTypeNames: [gqlType.name] } | ||
return await Promise.all(_.map(new Array(n), () => runQuery(args))) | ||
} | ||
|
||
describe(`query indexing`, () => { | ||
beforeEach(async () => { | ||
await lokiDb.start() | ||
store.dispatch({ type: `DELETE_CACHE` }) | ||
}) | ||
it(`does not create index when query run 1 time`, async () => { | ||
await runQueries(makeNodes(), 1) | ||
const coll = getNodeTypeCollection(`Test`) | ||
expect(coll.binaryIndices.hasOwnProperty(`foo`)).toEqual(false) | ||
}) | ||
|
||
it(`creates index when query run 5 times`, async () => { | ||
await runQueries(makeNodes(), 5) | ||
const coll = getNodeTypeCollection(`Test`) | ||
expect(coll.binaryIndices.hasOwnProperty(`foo`)).toEqual(true) | ||
}) | ||
}) | ||
} else { | ||
it(`skipping loki nodes-query-test`, () => { | ||
expect(true).toEqual(true) | ||
}) | ||
} | ||
// if (process.env.GATSBY_DB_NODES === `loki`) { | ||
// const _ = require(`lodash`) | ||
// const { GraphQLObjectType } = require(`graphql`) | ||
// const { store } = require(`../../../redux`) | ||
// const runQuery = require(`../nodes-query`) | ||
// const { getNodeTypeCollection } = require(`../nodes`) | ||
// const lokiDb = require(`../index`) | ||
// | ||
// function makeNodes() { | ||
// return [ | ||
// { | ||
// id: `1`, | ||
// internal: { type: `Test` }, | ||
// children: [], | ||
// foo: `bar`, | ||
// }, | ||
// ] | ||
// } | ||
// | ||
// async function runQueries(nodes, n) { | ||
// for (const node of nodes) { | ||
// store.dispatch({ type: `CREATE_NODE`, payload: node }) | ||
// } | ||
// const gqlType = new GraphQLObjectType({ | ||
// name: `Test`, | ||
// fields: { | ||
// foo: { type: `String` }, | ||
// }, | ||
// }) | ||
// const queryArgs = { filter: { foo: { eq: `bar` } } } | ||
// const args = { gqlType, queryArgs, nodeTypeNames: [gqlType.name] } | ||
// return await Promise.all(_.map(new Array(n), () => runQuery(args))) | ||
// } | ||
// | ||
// describe(`query indexing`, () => { | ||
// beforeEach(async () => { | ||
// await lokiDb.start() | ||
// store.dispatch({ type: `DELETE_CACHE` }) | ||
// }) | ||
// it(`does not create index when query run 1 time`, async () => { | ||
// await runQueries(makeNodes(), 1) | ||
// const coll = getNodeTypeCollection(`Test`) | ||
// expect(coll.binaryIndices.hasOwnProperty(`foo`)).toEqual(false) | ||
// }) | ||
// | ||
// it(`creates index when query run 5 times`, async () => { | ||
// await runQueries(makeNodes(), 5) | ||
// const coll = getNodeTypeCollection(`Test`) | ||
// expect(coll.binaryIndices.hasOwnProperty(`foo`)).toEqual(true) | ||
// }) | ||
// }) | ||
// } else { | ||
it(`skipping loki nodes-query-test`, () => { | ||
expect(true).toEqual(true) | ||
}) | ||
// } |
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