Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Remove location #258

Merged
merged 14 commits into from
Jul 11, 2018
Merged

Remove location #258

merged 14 commits into from
Jul 11, 2018

Conversation

ralphtheninja
Copy link
Member

Closes #63

Also see discussion from #256

)
t.end()
})

test('test database open no-arg throws', function (t) {
Copy link
Member Author

@ralphtheninja ralphtheninja Jul 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What to do with this file now? It only contains one test which doesn't do anything. I think we have two options here.

  1. We remove it completely
  2. We rewrite it to test other things that might be related to inheritance, such as checking for the complete api and not only .open
  3. Keep it as it is

If we go with 2 or 3, the current test should be renamed because it doesn't have anything to do with throw

Copy link
Member Author

@ralphtheninja ralphtheninja Jul 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd personally would go for 1.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to removing

@ralphtheninja ralphtheninja requested a review from vweevers July 10, 2018 09:31
@ralphtheninja
Copy link
Member Author

Restarting browser tests a second time.

@vweevers
Copy link
Member

What about the abstract tests?

db = leveldown(testCommon.location())

etc

@ralphtheninja
Copy link
Member Author

ralphtheninja commented Jul 10, 2018

@vweevers I thought I'd do a second PR for that.

@ralphtheninja
Copy link
Member Author

ralphtheninja commented Jul 10, 2018

Can fix in this PR as well if you want.

@ralphtheninja ralphtheninja changed the title Remove location Remove location [WIP] Jul 10, 2018
@ralphtheninja
Copy link
Member Author

Found this test which assumes location based implementations

test('test database open errorIfExists:true', function (t) {
var location = testCommon.location()
var db = leveldown(location)
// make a valid database first, then close and dispose
db.open({}, function (err) {
t.error(err)
db.close(function (err) {
t.error(err)
// open again with 'errorIfExists'
db = leveldown(location)
var async = false
db.open({ createIfMissing: false, errorIfExists: true }, function (err) {
t.ok(err, 'error')
t.ok(/exists/.test(err.message), 'error is about already existing')
t.ok(async, 'callback is asynchronous')
t.end()
})
async = true
})
})
})

Will comment out this for now.

})
})
})
// TODO this assumes location based backends, move out to respective
Copy link
Member Author

@ralphtheninja ralphtheninja Jul 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only test that assumes the (previous) leveldown parameter to accept a location argument (so it can try and open on the same location). We should either remove this and move to location based implementations, or move it to a location based file (e.g. test/leveldown-test.js).

However, it uses errorIfExists property which afaik is related to leveldown, so maybe we should just move it to LevelDB based implementations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why does this test need two db instances? If you open a db, close it, then reopen with errorIfExists, it should error too, right?

(Removing createIfMissing and errorIfExists from abstract-leveldown is probably a discussion for later)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in a rush right now. Will get back to this in a bit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vweevers Reverted the commit and brought back the test using a single db instance.

@ralphtheninja
Copy link
Member Author

@vweevers I could use some feedback on the TODO comments specifically.

@ralphtheninja
Copy link
Member Author

ralphtheninja commented Jul 10, 2018

Left to do:

  • some notes in UPGRADING.md on api changes Skipping this to next PR.
  • address TODO comments

README.md Outdated
function FakeLevelDOWN (location) {
AbstractLevelDOWN.call(this, location)
this.location = location
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well remove this too

test/common.js Outdated
var tempy = require('tempy')

module.exports = {
// TODO remove?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing SGTM. Implementations only have to call tempy.directory in their factory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! Also means we can merge common.js and common-browser.js into one file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh but we should document somewhere that each factory call should return a fresh db

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or add a test for this behavior :)

@vweevers
Copy link
Member

Would it make sense for factory to be part of testCommon?

@ralphtheninja
Copy link
Member Author

Would it make sense for factory to be part of testCommon?

It might make sense actually. The api would be a lot cleaner since (factory, test) and (factory, test, testCommon) could just be (test, testCommon).

Maybe merge those in another PR?

@vweevers
Copy link
Member

Maybe merge those in another PR?

👍

@vweevers
Copy link
Member

I love where this is going!

@ralphtheninja
Copy link
Member Author

I love where this is going!

Haha same here. Things just seemed to fall in place a lot when location was no longer something to consider.

@@ -80,35 +80,6 @@ module.exports.openAdvanced = function (factory, test) {

async = true
})

// TODO this assumes location based backends, move out to respective
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this, see #258 (comment)

@ralphtheninja
Copy link
Member Author

I added the tag pre-remove-location to current master. Creating a abstract-leveldown-v6 branch in leveldown to try out the new changes to see if we are running into something unforeseen. Keeping WIP status of this PR for a while.

@ralphtheninja ralphtheninja changed the title Remove location [WIP] Remove location Jul 10, 2018
@ralphtheninja
Copy link
Member Author

Rebased onto latest master (without node 9 so faster builds yay!)

@@ -1,9 +1,4 @@
var collectEntries = require('level-concat-iterator')
var tempy = require('tempy')

module.exports = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could export a function here instead? E.g.

module.exports = function (opts) {
  return xtend({
    setUp: function (t) { t.end() },
    tearDown: function (t) { t.end() }
  }, opts)
}

@ralphtheninja
Copy link
Member Author

@vweevers Sorry to be a pain. Good to squash?

@vweevers
Copy link
Member

Can you give me until tonight (~6 hours from now)?

@ralphtheninja
Copy link
Member Author

Can you give me until tonight (~6 hours from now)?

For sure!

@@ -82,20 +82,17 @@ module.exports.openAdvanced = function (leveldown, test, testCommon) {
})

test('test database open errorIfExists:true', function (t) {
var location = testCommon.location()
var db = leveldown(location)
var db = factory()

// make a valid database first, then close and dispose
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover comment: " and dispose"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the comments altogether.

@vweevers
Copy link
Member

@ralphtheninja Can you open issues for:

  • Document that each factory call must return a fresh db
  • Test that each factory call returns a fresh db (open two dbs, write to first, check that second is empty)
  • Consider exporting testCommon as function
  • Update upgrade guide (also for seek)

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants