-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add project.close()
#375
Changes from 12 commits
8adec47
7529dc6
356d4ee
1df497d
e3c395c
0e7ce31
1062410
3e33597
ef7f93e
bd88106
904ee40
f218f09
6774279
57ba9fc
5fee846
1ad7057
a1b742e
c286486
d54311b
fd83222
169af66
02ba36e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,6 +124,62 @@ test('CRUD operations', async (t) => { | |
'expected values returns from getMany()' | ||
) | ||
}) | ||
t.test('create, close and then create, update', async (st) => { | ||
const projectId = await manager.createProject() | ||
const project = await manager.getProject(projectId) | ||
const values = new Array(5).fill(null).map(() => { | ||
return getUpdateFixture(value) | ||
}) | ||
for (const value of values) { | ||
// @ts-ignore | ||
await project[schemaName].create(value) | ||
} | ||
// @ts-ignore | ||
const written = await project[schemaName].create(value) | ||
await project.close() | ||
|
||
await st.exception(async () => { | ||
const updateValue = getUpdateFixture(value) | ||
// @ts-ignore | ||
await project[schemaName].update(written.versionId, updateValue) | ||
}, 'should fail updating since the project is already closed') | ||
|
||
await st.exception(async () => { | ||
for (const value of values) { | ||
// @ts-ignore | ||
await project[schemaName].create(value) | ||
} | ||
}, 'should fail creating since the project is already closed') | ||
|
||
// @ts-ignore | ||
await st.exception.all(async () => { | ||
await project[schemaName].getMany() | ||
}, 'should fail getting since the project is already closed') | ||
}) | ||
t.test( | ||
'create project, close, then re-create a project and create', | ||
async (st) => { | ||
// create project | ||
const projectId = await manager.createProject() | ||
const project = await manager.getProject(projectId) | ||
// close it | ||
await project.close() | ||
// re create project | ||
const newProjectId = await manager.createProject() | ||
const newProject = await manager.getProject(newProjectId) | ||
const newValues = new Array(5).fill(null).map(() => { | ||
return getUpdateFixture(value) | ||
}) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't really testing anything - it's closing one project and creating a different one. Is this meant to test closing then re-opening a project? Then it should use the same projectId and check the data that was written before close is still there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I realize this was the purpose of this tests. But I'm wondering how to achieve that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tomasciccola all of the storage instances will be re-created when you call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see 5fee846 for relevant change |
||
for (const value of newValues) { | ||
await st.execution( | ||
// @ts-ignore | ||
await newProject[schemaName].create(value), | ||
'create after `project.close()` and creating new project' | ||
) | ||
} | ||
} | ||
) | ||
} | ||
}) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should only remove listeners that this class has added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. The MultiCoreIndexer is already doing that, so I'll just remove that line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added relevant change in 1ad7057 to remove the listeners added to the
LocalPeers
instance in the constructor. @gmaclennan lmk if this seems like the correct way to go about it