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

Commit

Permalink
kdb: fix kdbGet never returns 0
Browse files Browse the repository at this point in the history
  • Loading branch information
kodebach committed Nov 10, 2022
1 parent ad1db9d commit 85e8e19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libs/elektra/kdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1809,7 +1809,7 @@ int kdbGet (KDB * handle, KeySet * ks, Key * parentKey)
ksDel (backends);
ksDel (allBackends);
errno = errnosave;
return 2;
return ksGetSize (backends) == 0 ? 0 : 2;
}

// check if cache is enabled, Steps 7-9 only run with cache
Expand Down
8 changes: 8 additions & 0 deletions tests/kdb/testkdb_simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,11 @@ TEST_F (Simple, TriggerError)
ASSERT_EQ (ks.size (), 3) << "key suddenly missing";
ASSERT_EQ (stat (mp->systemConfigFile.c_str (), &buf), -1) << "created file even though error triggered";
}

TEST_F (Simple, NothingToDo)
{
using namespace kdb;
KDB kdb;
KeySet ks;
EXPECT_EQ (kdb.get (ks, "system:" + testRoot), 0) << "nothing to do in get";
}

0 comments on commit 85e8e19

Please sign in to comment.