Skip to content

Commit

Permalink
feat: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ouertani committed Oct 24, 2024
1 parent d5d7956 commit f6c08e0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Options:
--chrono-dates Use chrono::NaiveDateTime for date/timestamps logical types
--derive-builders Derive builders for generated record structs
--derive-schemas Derive AvroSchema for generated record structs
--extra_derives Append extra derive macros to the generated record structs
--extra_derive Append one extra derive macros to the generated record structs
--extra_derives Append extra derive macros list to the generated record structs
-h, --help Print help
-V, --version Print version
```
Expand Down
8 changes: 8 additions & 0 deletions src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ impl GeneratorBuilder {
self
}

/// Adds support to derive custom macros.
///
/// Applies to record structs.
pub fn extra_derive(mut self, extra_derive: &str) -> GeneratorBuilder {
self.extra_derives.push(extra_derive.to_string());
self
}

/// Create a [`Generator`](Generator) with the builder parameters.
pub fn build(self) -> Result<Generator> {
let mut templater = Templater::new()?;
Expand Down
2 changes: 1 addition & 1 deletion tests/generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ fn gen_one_extra_derives() {
validate_generation(
"one_extra_derive",
Generator::builder()
.extra_derives(vec!["std::fmt::Display".to_string()])
.extra_derive("std::fmt::Display")
.build()
.unwrap(),
);
Expand Down

0 comments on commit f6c08e0

Please sign in to comment.