Skip to content

Commit

Permalink
add QuotaType::kHard
Browse files Browse the repository at this point in the history
  • Loading branch information
atimin committed Sep 12, 2024
1 parent 6a498ba commit 3779578
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/reduct/bucket.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class IBucket {
public:
virtual ~IBucket() = default;

enum class QuotaType { kNone, kFifo };
enum class QuotaType { kNone, kFifo, kHard };

/**
* Bucket Settings
Expand Down
5 changes: 5 additions & 0 deletions src/reduct/internal/serialisation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ nlohmann::json BucketSettingToJsonString(const IBucket::Settings& settings) {
case IBucket::QuotaType::kFifo:
data["quota_type"] = "FIFO";
break;
case IBucket::QuotaType::kHard:
data["quota_type"] = "HARD";
break;
}
}

Expand All @@ -51,6 +54,8 @@ Result<IBucket::Settings> ParseBucketSettings(const nlohmann::json& json) {
settings.quota_type = IBucket::QuotaType::kNone;
} else if (json["quota_type"] == "FIFO") {
settings.quota_type = IBucket::QuotaType::kFifo;
} else if (json["quota_type"] == "HARD") {
settings.quota_type = IBucket::QuotaType::kHard;
}
}

Expand Down
15 changes: 15 additions & 0 deletions tests/reduct/bucket_api_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,21 @@ TEST_CASE("reduct::Client should get or create a bucket", "[bucket_api]") {
REQUIRE(bucket);
}

TEST_CASE("reduct::Client should create a bucket with different quota type", "[bucket_api][1_12]") {
Fixture ctx;

auto quota_type = GENERATE(IBucket::QuotaType::kNone, IBucket::QuotaType::kFifo, IBucket::QuotaType::kHard);
[[maybe_unused]] auto _ = ctx.client->GetOrCreateBucket(kBucketName, {.quota_type = quota_type});
auto [bucket, err] = ctx.client->GetOrCreateBucket(kBucketName);

REQUIRE(err == Error::kOk);
REQUIRE(bucket);

auto [settings, get_error] = bucket->GetSettings();
REQUIRE(get_error == Error::kOk);
REQUIRE(settings.quota_type == quota_type);
}

TEST_CASE("reduct::IBucket should have settings", "[bucket_api]") {
Fixture ctx;
const IBucket::Settings kSettings{
Expand Down

0 comments on commit 3779578

Please sign in to comment.