Skip to content

Commit fac08cf

Browse files
Merge pull request #77 from frossq/fix-intf-validation
Improve consistency of 'database_retention_policy' and 'database_retention_ttl' values in interface aggregate mappings
2 parents 200fd85 + 6eb0988 commit fac08cf

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

lib/astarte/core/generators/interface.ex

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# This file is part of Astarte.
33
#
4-
# Copyright 2025 SECO Mind Srl
4+
# Copyright 2025 - 2026 SECO Mind Srl
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -207,13 +207,19 @@ defmodule Astarte.Core.Generators.Interface do
207207
reliability <- MappingGenerator.reliability(interface_type),
208208
expiry <- MappingGenerator.expiry(interface_type),
209209
allow_unset <- MappingGenerator.allow_unset(interface_type),
210-
explicit_timestamp <- MappingGenerator.explicit_timestamp(interface_type) do
210+
explicit_timestamp <- MappingGenerator.explicit_timestamp(interface_type),
211+
db_retention_policy <-
212+
MappingGenerator.database_retention_policy(interface_type),
213+
db_retention_ttl <-
214+
MappingGenerator.database_retention_ttl(interface_type, db_retention_policy) do
211215
[
212216
retention: retention,
213217
reliability: reliability,
214218
expiry: expiry,
215219
allow_unset: allow_unset,
216-
explicit_timestamp: explicit_timestamp
220+
explicit_timestamp: explicit_timestamp,
221+
database_retention_policy: db_retention_policy,
222+
database_retention_ttl: db_retention_ttl
217223
]
218224
end
219225

test/astarte/core/generators/interface_test.exs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# This file is part of Astarte.
33
#
4-
# Copyright 2025 SECO Mind Srl
4+
# Copyright 2025 - 2026 SECO Mind Srl
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -171,6 +171,25 @@ defmodule Astarte.Core.Generators.InterfaceTest do
171171
assert changeset.valid?, "Invalid interface: #{inspect(changeset.errors)}"
172172
end
173173
end
174+
175+
@tag issue: 1072
176+
property "validate database retention opts in interface aggregate mappings are consistent" do
177+
check all interface <- InterfaceGenerator.interface(), max_runs: 100 do
178+
%Mapping{
179+
database_retention_policy: reference_database_retention_policy,
180+
database_retention_ttl: reference_database_retention_ttl
181+
} = Enum.at(interface.mappings, 0)
182+
183+
assert Enum.all?(interface.mappings, fn
184+
%Mapping{
185+
database_retention_policy: mapping_database_retention_policy,
186+
database_retention_ttl: mapping_database_retention_ttl
187+
} ->
188+
mapping_database_retention_policy == reference_database_retention_policy and
189+
mapping_database_retention_ttl == reference_database_retention_ttl
190+
end)
191+
end
192+
end
174193
end
175194

176195
describe "to_changes/1" do

0 commit comments

Comments
 (0)