Commit Graph

588 Commits

Author SHA1 Message Date
Matthias Beyer 7050067675 Merge pull request #761 from matthiasbeyer/libimagstore/store-tests-more-succeeding-hook-tests
libimagstore/store-tests: more succeeding hook tests
2016-10-09 13:29:48 +02:00
Matthias Beyer 5202c5112a Add flag for _update() whether precense should be modified
This is a bugfix for an very particular issue.

Here's what happens:

If we create() an FileLockEntry and then update() it, we are running
into a problem because update() calls _update() which changes the
precense status of a FileLockEntry.

Because update() is _consuming_, the FileLockEntry gets drop()ed
afterwards. This _again_ causes _update() to be called, but with a new
presence status, which is not true in this moment (as the FileLockEntry
is still borrowed, but we already marked it as present).

This patch is a short-term fix. The real problem is, that our Store
interface is consuming. If the Store interface would be non-consuming,
this issue wouldn't happen, as the drop() call would not happen.

I'm rather sure that this patch will not be reverted in the process of
rewriting the Store interface to be non-consuming. But we never know.
2016-10-07 21:59:37 +02:00
Matthias Beyer 7b11e7dabb Add testing implementation for Drop for FileLockEntry 2016-10-07 21:59:37 +02:00
Matthias Beyer d375a6d2c6 Add output to test helper, so we can see in the trace whats happening 2016-10-07 21:59:37 +02:00
Matthias Beyer ae66b00f5f store tests: Add erroring-hook-tests 2016-10-07 21:59:37 +02:00
Matthias Beyer 095ae19416 [CHERRY-PICK] Add flag for _update() whether precense should be modified
This is a bugfix for an very particular issue.

Here's what happens:

If we create() an FileLockEntry and then update() it, we are running
into a problem because update() calls _update() which changes the
precense status of a FileLockEntry.

Because update() is _consuming_, the FileLockEntry gets drop()ed
afterwards. This _again_ causes _update() to be called, but with a new
presence status, which is not true in this moment (as the FileLockEntry
is still borrowed, but we already marked it as present).

This patch is a short-term fix. The real problem is, that our Store
interface is consuming. If the Store interface would be non-consuming,
this issue wouldn't happen, as the drop() call would not happen.

I'm rather sure that this patch will not be reverted in the process of
rewriting the Store interface to be non-consuming. But we never know.
2016-10-07 21:18:49 +02:00
Matthias Beyer cf50ddae33 [CHERRY-PICK] Add testing implementation for Drop for FileLockEntry 2016-10-07 21:18:49 +02:00
Matthias Beyer 485d280236 Bugfix: The StoreEntry should know the _new_ StoreId
When moving a entry in the store, we also should tell the StoreEntry
the new id.
2016-10-07 21:18:49 +02:00
Matthias Beyer c72291159e Add comment/documentation for Store::move_by_id() 2016-10-07 17:53:11 +02:00
Matthias Beyer b189bf7b8c Add check if entry is present
If we try to rename an entry that is borrowed, we fail, as renaming an
borrowed entry might result in some _really_ ugly bugs.
2016-10-07 17:32:35 +02:00
Matthias Beyer 1e83ad7bbd Add test for hook execution for each hook position 2016-10-07 17:32:35 +02:00
Matthias Beyer d9f4898a3a Abstract testing of hook execution in helper function 2016-10-07 17:32:35 +02:00
Matthias Beyer dd621a08a6 Merge pull request #772 from matthiasbeyer/libimagstore/store-tests-erroring-hooks
libimagstore/store-tests: erroring hooks
2016-10-06 18:30:24 +02:00
Matthias Beyer 1244a6666f Add assert to Store::get() the new ID 2016-10-03 12:34:07 +02:00
Matthias Beyer 6cc1a90870 libimagstore: Add copyright notice to all files 2016-10-01 17:35:06 +02:00
Matthias Beyer 1526c0b2dc Make hook configurable whether it succeeds or not 2016-09-30 13:39:33 +02:00
Matthias Beyer f16c09a981 Do not check whether old or new id exists/does not exist 2016-09-30 13:20:37 +02:00
Matthias Beyer 886eed3ff4 Rename: SucceedingHook -> TestHook 2016-09-22 08:47:29 +02:00
Matthias Beyer 4f83b22b98 Fix Store::move_by_id(): Move in cache as well 2016-09-22 08:42:19 +02:00
Matthias Beyer caa214f1bd Fix negation error
We check whether the old key already exists.

If it does _not_ exist, the entry is borrowed, from my understanding.
I'm not sure, though.
2016-09-22 08:41:12 +02:00
Matthias Beyer d5a275fec0 Add test: Store::move_by_id() 2016-09-22 08:41:01 +02:00
Matthias Beyer 61201082c8 Fix: FileAbstraction::remove_file(): Add implementation 2016-09-21 10:20:16 +02:00
Matthias Beyer babf74e1e5 Fix Store::get() to not check FS but internal hashmap 2016-09-21 10:20:16 +02:00
Matthias Beyer 4f2019a20a Extend test_store_create_delete_get()
to actually test:

1. get      -> Should return Ok(None)
2. create   -> Should return Ok(())
3. get      -> Should return Ok(Some(_))
4. delete   -> Should return Ok(())
5. get      -> Should return Ok(None)
2016-09-21 09:52:37 +02:00
Matthias Beyer 513a9bd066 Merge pull request #751 from matthiasbeyer/libimagstore/store-tests-succeeding-hook-tests
libimagstore/store: tests succeeding hook tests
2016-09-19 22:39:23 +02:00
Matthias Beyer 72a95ee5da Rewrite config validity checker to return Result<()>
And add more detailed error kinds for config errors
2016-09-19 21:52:28 +02:00
Matthias Beyer 83ebe88022 Add PreCreate hook test 2016-09-19 21:51:14 +02:00
Matthias Beyer 4155924f85 Add test for Store::retrieve_for_module() 2016-09-19 11:25:36 +02:00
Matthias Beyer fd41fe5998 Fix Store::delete() for nonexistent IDs
If the ID does not exist, we should return an error instead of doing
nothing, shouldn't we?
2016-09-19 11:07:38 +02:00
Matthias Beyer 8345ff8248 Add test to delete non-existent entries 2016-09-19 11:03:38 +02:00
Matthias Beyer 52b2a4589d Add test to get non-existent entries 2016-09-19 11:01:56 +02:00
Matthias Beyer de6b641201 Merge branch 'master' into libimagstorestdhook/git-integration
This is a integration-merge, because the libimagstorestdhook/git branch
got really long and rebasing is not an option, as it would mainly
destroy history.

Using an integration branch is less hassle, really.
2016-09-19 10:44:57 +02:00
Matthias Beyer 85097554e9 Add hook implementation for succeeding hook tests 2016-09-19 10:38:46 +02:00
Matthias Beyer 0cdeeb4c55 Fix test backend implementation
We must return an error if the file is not found here.

This is because if we unwrap() here, we panic if the store action was
Store::retrieve() and there wasn't a file there. We then unwrap() on
None and panic because of this, causing all other tests to panic as
well because the Mutex gets corrupted.

The store handles FileNotFound errors on its own, so it is safe to
return the error here.
2016-09-19 10:37:28 +02:00
Matthias Beyer 07ff755ed7 Minify error handling in Store::_update with try!() 2016-09-18 14:52:55 +02:00
Matthias Beyer b288e938f9 Minify error handling in Store::update() 2016-09-18 14:52:00 +02:00
Matthias Beyer 41c7cd2363 [CHERRY-PICK] Add newline before header
The lastest release of the `toml-rs` crate (2.1) removes leading spaces
before arrays and tables, causing our tests to fail.

This fixes it.
2016-09-09 17:22:20 +02:00
Matthias Beyer d5647069cb Add test that Store::retrieve() does ::create() underneath 2016-09-09 13:07:46 +02:00
Matthias Beyer c9994c33b6 Add test whether store-internal hashmap gets actually filled on Store::create() 2016-09-09 13:07:45 +02:00
Matthias Beyer e023a856f1 Add Store testing 2016-09-09 13:07:32 +02:00
Matthias Beyer ff5a4b46c7 Remove StoreId::is_file() 2016-09-09 12:56:29 +02:00
Matthias Beyer 21714660df Merge pull request #729 from matthiasbeyer/fix-header-missing-newline
Add newline before header
2016-09-09 12:54:28 +02:00
Matthias Beyer 7b827ff149 Add newline before header
The lastest release of the `toml-rs` crate (2.1) removes leading spaces
before arrays and tables, causing our tests to fail.

This fixes it.
2016-09-09 11:52:12 +02:00
Matthias Beyer 88ff94fb6d Remove StoreId::is_dir() 2016-09-08 15:05:25 +02:00
Matthias Beyer 3252f9b751 Move Update-Hook execution into Store._update() 2016-09-08 14:23:10 +02:00
Matthias Beyer d1fee32c7d Just do not execute mutable hooks, but let pass the nonmutables 2016-09-07 22:05:30 +02:00
Matthias Beyer af4a0bfaf2 Export result-helper here 2016-09-06 15:31:55 +02:00
Matthias Beyer 5f04d29345 Adapt store to not use StoreId::into() but new StoreId::into_pathbuf() 2016-09-06 15:31:55 +02:00
Matthias Beyer a313cede06 Add StoreId::into_pathbuf() 2016-09-06 15:31:55 +02:00
Matthias Beyer b8f612632d Add error kind if StoreId has no base part 2016-09-06 15:31:29 +02:00
Matthias Beyer 84b279de95 Remove Into<PathBuf> for StoreId 2016-09-06 15:31:29 +02:00
Matthias Beyer aa7e050436 Merge pull request #707 from matthiasbeyer/libimagstore/remove-storeid-storified
Remove StoreId::storified()
2016-09-06 12:31:01 +02:00
Matthias Beyer d7447a64c8 Remove StoreId::storified() 2016-09-06 09:37:25 +02:00
Matthias Beyer 364ad01179 Use StoreId::from_full_path() in GlobStoreIdIterator::next() 2016-09-05 18:22:55 +02:00
Matthias Beyer 8362b077e2 Add StoreId::from_full_path() 2016-09-05 18:21:34 +02:00
Matthias Beyer f60afa581c Add error type for failed build of StoreId object from full path 2016-09-05 18:21:21 +02:00
Matthias Beyer e4e5b52171 Fix Iterator impl for GlobStoreIdIterator
This patch fixes the `impl Iterator for GlobStoreIdIterator` which used
the glob() result to fetch the files from the FS, but glob() returns the
absolute pathes (to filesystem root).

We have to strip the `store_path` prefix and use the local part for
building the StoreId object.
2016-09-05 18:12:29 +02:00
Matthias Beyer ccffeb91a2 Remove StoreId::is_in_collection(), add StoreId::local()
Having a ::is_in_collection() is a nice thing, though it is _way_ better
if we just give the user of the `StoreId` object access to the local
part of the ID.

Using this new function, one can do all the actions one might need on
the Path for the actual entry without nasty copying or such.

`StoreId::is_in_collection()` can be replaced by
`StoreId::local().starts_with()` and everything is fine, as we do not
have to move a `PathBuf` object into the function anymore.
2016-09-04 10:40:38 +02:00
Matthias Beyer 253c8a6f54 Adapt tests for new StoreId::is_in_collection() interface 2016-09-03 19:32:27 +02:00
Matthias Beyer a77cc2bab2 Change the interface of StoreId::is_in_collection()
to use &PathBuf rather than &[&str] as argument.
2016-09-02 17:15:15 +02:00
Matthias Beyer 85f79ae3e5 Replace .map().all(|x| x) by calling .all() in the first place 2016-09-02 17:01:40 +02:00
Matthias Beyer 4896c14086 Merge pull request #681 from matthiasbeyer/rewrite-storeid-type-cleanup-libimagentrylink
libimagentrylink cleanup
2016-09-02 08:25:10 +02:00
Matthias Beyer b2806ab592 Add StoreId::is_in_collection()
The concept of this function was introduced in

    37076f028c6cde0924b820154f3464f53ef65268

but here added to StoreId as function.
2016-08-31 09:20:08 +02:00
Matthias Beyer 22d6815abd Remove Store::get_all_versions() as we do not longer have the concept of store-entry versions 2016-08-31 08:26:54 +02:00
Matthias Beyer 82f08c6021 Remove version argument from module_entry_path_mod!() macro 2016-08-30 11:40:56 +02:00
Matthias Beyer ec2eb096e7 Remove id part from macro 2016-08-30 11:40:56 +02:00
Matthias Beyer fedb75ec98 Impl IntoStoreId for PathBuf, using StoreId::new_baseless() 2016-08-28 18:41:56 +02:00
Matthias Beyer 5462714fcc Remove libimagstore::storeid::build_entry_path() 2016-08-28 18:41:56 +02:00
Matthias Beyer d252623b75 Add StoreId::components() to get components of StoreId "id" part 2016-08-28 18:41:55 +02:00
Matthias Beyer 197940ac33 Fixup Store test implementations 2016-08-28 18:41:55 +02:00
Matthias Beyer d538a5b380 Fixup StoreId test 2016-08-28 18:41:55 +02:00
Matthias Beyer fd1a96fa74 Fix storification of StoreId in CRUD functions 2016-08-28 18:41:55 +02:00
Matthias Beyer 4c435d9347 Add StoreId::with_base() 2016-08-28 18:41:54 +02:00
Matthias Beyer 784f1cc4c6 Fix interface of IntoStoreId trait to return Result<StoreId> and impls 2016-08-28 18:41:54 +02:00
Matthias Beyer 40f1efa258 Fix for new StoreId interface in Iterator for Walk impl 2016-08-28 18:41:54 +02:00
Matthias Beyer a110ecc2ec Fix GlobStoreIdIterator implementation for new StoreId interface 2016-08-28 18:41:54 +02:00
Matthias Beyer 151877d95d Fix impl Drop for Store for new StoreId interface 2016-08-28 18:41:54 +02:00
Matthias Beyer d5723791a6 Add StoreId::without_base() 2016-08-28 18:41:54 +02:00
Matthias Beyer ab23d04e04 Add StoreId::new_baseless() 2016-08-28 18:41:54 +02:00
Matthias Beyer d1f07cd087 Add check in StoreId::new() whether the local part is absolute 2016-08-28 18:41:54 +02:00
Matthias Beyer ccc2b6b735 Add error kind for StoreId::new() with id-part that is absolute 2016-08-28 18:41:54 +02:00
Matthias Beyer 5b23059d93 Fix scoping 2016-08-28 18:41:54 +02:00
Matthias Beyer 3c1be0fbe9 Fix use of store ids when passing to FileAbstraction::* 2016-08-28 18:41:54 +02:00
Matthias Beyer 111cb4f29a Add StoreId::to_str() -> String 2016-08-28 18:41:54 +02:00
Matthias Beyer aa6f220659 Fix GlobStoreIterator type implementation
... to use new StoreId interface
2016-08-28 18:41:53 +02:00
Matthias Beyer 3f88c27834 Remove unused imports 2016-08-28 18:41:53 +02:00
Matthias Beyer 9cf7897286 Fixup Walk type to handle StoreId properly 2016-08-28 18:41:53 +02:00
Matthias Beyer 1de09f1606 Rewrite StoreId::storified() 2016-08-28 18:41:53 +02:00
Matthias Beyer 1af3ab018b Use StoreId::new() in macro 2016-08-28 18:41:53 +02:00
Matthias Beyer fe73a53d44 Add StoreId::new() 2016-08-28 18:41:53 +02:00
Matthias Beyer 8dff5685fd Make StoreId.base optional 2016-08-28 18:41:53 +02:00
Matthias Beyer ad92b05fb4 Remove IntoStoreId for PathBuf 2016-08-28 18:41:53 +02:00
Matthias Beyer adf213bbc7 Remove From<PathBuf> for StoreId 2016-08-28 18:41:53 +02:00
Matthias Beyer cf84df3ce7 Remove From<String> for StoreId 2016-08-28 18:41:53 +02:00
Matthias Beyer bcd917055d Remove AsRef<Path> for StoreId 2016-08-28 18:41:53 +02:00
Matthias Beyer 30a76d57f6 Remove Borrow<Path> for StoreId 2016-08-28 18:41:53 +02:00
Matthias Beyer 8c5a427a01 Rewrite Borrow<Path> for StoreId 2016-08-28 18:41:52 +02:00
Matthias Beyer 55953cfe5b Rewrite AsRef<Path> for StoreId 2016-08-28 18:41:52 +02:00
Matthias Beyer 1d165f6fc2 Remove Deref for StoreId but provide basic functions within the type 2016-08-28 18:41:52 +02:00
Matthias Beyer 69b3f6bf87 Rewrite Display for StoreId 2016-08-28 18:41:52 +02:00