• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender / 1022753986

02 Oct 2023 10:37AM UTC coverage: 78.168% (-2.0%) from 80.127%
1022753986

push

gitlab-ci

oleorhagen
feat: Run the authentication loop once upon bootstrap

Ticket: MEN-6658
Changelog: None

Signed-off-by: Ole Petter <ole.orhagen@northern.tech>

32 of 32 new or added lines in 1 file covered. (100.0%)

6996 of 8950 relevant lines covered (78.17%)

10353.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

34.78
/common/key_value_database.cpp
1
// Copyright 2023 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
#include <common/key_value_database.hpp>
16

17
#include <common/common.hpp>
18

19
namespace mender {
20
namespace common {
21
namespace key_value_database {
22

23
namespace common = mender::common;
24

25
const KeyValueDatabaseErrorCategoryClass KeyValueDatabaseErrorCategory =
26
        KeyValueDatabaseErrorCategoryClass();
27

28
const char *KeyValueDatabaseErrorCategoryClass::name() const noexcept {
×
29
        return "KeyValueDatabaseErrorCategory";
×
30
}
31

32
string KeyValueDatabaseErrorCategoryClass::message(int code) const {
×
33
        switch (code) {
×
34
        case NoError:
×
35
                return "Success";
×
36
        case KeyError:
×
37
                return "Key error";
×
38
        case LmdbError:
×
39
                return "LMDB error";
×
40
        case AlreadyExistsError:
×
41
                return "Key already exists";
×
42
        default:
×
43
                return "Unknown";
×
44
        }
45
}
46

47
Error MakeError(ErrorCode code, const string &msg) {
1,554✔
48
        return Error(error_condition(code, KeyValueDatabaseErrorCategory), msg);
3,108✔
49
}
50

51
Error ReadString(Transaction &txn, const string &key, string &value_str, bool missing_ok) {
1,074✔
52
        auto ex_bytes = txn.Read(key);
2,148✔
53
        if (!ex_bytes) {
1,074✔
54
                if (!missing_ok || (ex_bytes.error().code != MakeError(KeyError, "").code)) {
1,258✔
55
                        return ex_bytes.error();
×
56
                }
57
        } else {
58
                value_str = common::StringFromByteVector(ex_bytes.value());
445✔
59
        }
60
        return error::NoError;
1,074✔
61
}
62

63
} // namespace key_value_database
64
} // namespace common
65
} // namespace mender
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc