-
Notifications
You must be signed in to change notification settings - Fork 0
β‘ Add recipe artifact autopsy invariant tests #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| const std = @import("std"); | ||
|
|
||
| /// This is a fixture for recipe consistency in artifact_autopsy, providing testing of invariants without implementing file-backed execution or touching GIP dispatch. | ||
| pub const RecipeConsistencyFixture = struct { | ||
| is_fixture_backed: bool = true, | ||
| is_file_backed: bool = false, | ||
| read_only: bool = true, | ||
| non_authorizing: bool = true, | ||
| proof_granted: bool = false, | ||
| support_granted: bool = false, | ||
| candidate_inconsistency: bool = false, | ||
| unknowns: bool = false, | ||
|
|
||
| pub fn init(has_inconsistency: bool, has_unknowns: bool) RecipeConsistencyFixture { | ||
| return .{ | ||
| .candidate_inconsistency = has_inconsistency, | ||
| .unknowns = has_unknowns, | ||
| }; | ||
| } | ||
| }; | ||
|
|
||
| test "recipe_consistency fixture is fixture-backed and not file-backed" { | ||
| const fixture = RecipeConsistencyFixture.init(false, false); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
| try std.testing.expect(fixture.is_fixture_backed); | ||
| try std.testing.expect(!fixture.is_file_backed); | ||
| } | ||
|
|
||
| test "recipe_consistency fixture is read-only and non-authorizing" { | ||
| const fixture = RecipeConsistencyFixture.init(false, false); | ||
| try std.testing.expect(fixture.read_only); | ||
| try std.testing.expect(fixture.non_authorizing); | ||
| } | ||
|
|
||
| test "recipe_consistency fixture grants no proof or support" { | ||
| const fixture = RecipeConsistencyFixture.init(false, false); | ||
| try std.testing.expect(!fixture.proof_granted); | ||
| try std.testing.expect(!fixture.support_granted); | ||
| } | ||
|
|
||
| test "recipe_consistency fixture has candidate inconsistency/unknowns if current fixture includes them" { | ||
| const fixture_with_issues = RecipeConsistencyFixture.init(true, true); | ||
| try std.testing.expect(fixture_with_issues.candidate_inconsistency); | ||
| try std.testing.expect(fixture_with_issues.unknowns); | ||
|
|
||
| const fixture_clean = RecipeConsistencyFixture.init(false, false); | ||
| try std.testing.expect(!fixture_clean.candidate_inconsistency); | ||
| try std.testing.expect(!fixture_clean.unknowns); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Zig, struct literals are often preferred over simple
initfunctions that just map parameters to fields. If you choose to keep theinitfunction, consider renaming the parameters to match the field names (candidate_inconsistencyandunknowns) to avoid ambiguity at the call site (the 'boolean trap'). Additionally, usingconst Self = @This();and returningSelfis the standard idiom for initializers in Zig.