release-plz 0.3.71

Update version and changelog based on semantic versioning and conventional commits
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
use cargo_metadata::camino::Utf8Path;
use cargo_utils::to_utf8_pathbuf;
use release_plz_core::{fs_utils::to_utf8_path, ReleaseRequest, UpdateRequest};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, path::PathBuf, time::Duration};
use url::Url;

use crate::changelog_config::ChangelogCfg;

/// You can find the documentation of the configuration file
/// [here](https://release-plz.ieni.dev/docs/config).
#[derive(Serialize, Deserialize, Default, PartialEq, Eq, Debug, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Config {
    /// # Workspace
    /// Global configuration. Applied to all packages by default.
    #[serde(default)]
    pub workspace: Workspace,
    #[serde(default)]
    pub changelog: ChangelogCfg,
    /// # Package
    /// Package-specific configuration. This overrides `workspace`.
    /// Not all settings of `workspace` can be overridden.
    #[serde(default)]
    package: Vec<PackageSpecificConfigWithName>,
}

impl Config {
    /// Package-specific configurations.
    /// Returns `<package name, package config>`.
    fn packages(&self) -> HashMap<&str, &PackageSpecificConfig> {
        self.package
            .iter()
            .map(|p| (p.name.as_str(), &p.config))
            .collect()
    }

    pub fn fill_update_config(
        &self,
        is_changelog_update_disabled: bool,
        update_request: UpdateRequest,
    ) -> UpdateRequest {
        let mut default_update_config = self.workspace.packages_defaults.clone();
        if is_changelog_update_disabled {
            default_update_config.changelog_update = false.into();
        }
        let mut update_request =
            update_request.with_default_package_config(default_update_config.into());
        for (package, config) in self.packages() {
            let mut update_config = config.clone();
            update_config = update_config.merge(self.workspace.packages_defaults.clone());
            if is_changelog_update_disabled {
                update_config.common.changelog_update = false.into();
            }
            update_request = update_request.with_package_config(package, update_config.into());
        }
        update_request
    }

    pub fn fill_release_config(
        &self,
        allow_dirty: bool,
        no_verify: bool,
        release_request: ReleaseRequest,
    ) -> ReleaseRequest {
        let mut default_config = self.workspace.packages_defaults.clone();
        if no_verify {
            default_config.publish_no_verify = Some(true);
        }
        if allow_dirty {
            default_config.publish_allow_dirty = Some(true);
        }
        let mut release_request =
            release_request.with_default_package_config(default_config.into());

        for (package, config) in self.packages() {
            let mut release_config = config.clone();
            release_config = release_config.merge(self.workspace.packages_defaults.clone());

            if no_verify {
                release_config.common.publish_no_verify = Some(true);
            }
            if allow_dirty {
                release_config.common.publish_allow_dirty = Some(true);
            }
            release_request =
                release_request.with_package_config(package, release_config.common.into());
        }
        release_request
    }
}

/// Config at the `[workspace]` level.
#[derive(Serialize, Deserialize, Default, PartialEq, Eq, Debug, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct Workspace {
    /// Configuration applied at the `[[package]]` level, too.
    #[serde(flatten)]
    pub packages_defaults: PackageConfig,
    /// # Allow Dirty
    /// - If `true`, allow dirty working directories to be updated. The uncommitted changes will be part of the update.
    /// - If `false` or [`Option::None`], the command will fail if the working directory is dirty.
    pub allow_dirty: Option<bool>,
    /// # Changelog Config
    /// Path to the git cliff configuration file. Defaults to the `keep a changelog` configuration.
    pub changelog_config: Option<PathBuf>,
    /// # Dependencies Update
    /// - If `true`, update all the dependencies in the Cargo.lock file by running `cargo update`.
    /// - If `false` or [`Option::None`], only update the workspace packages by running `cargo update --workspace`.
    pub dependencies_update: Option<bool>,
    /// # PR Draft
    /// If `true`, the created release PR will be marked as a draft.
    #[serde(default)]
    pub pr_draft: bool,
    /// # PR Labels
    /// Labels to add to the release PR.
    #[serde(default)]
    pub pr_labels: Vec<String>,
    /// # Publish Timeout
    /// Timeout for the publishing process
    pub publish_timeout: Option<String>,
    /// # Repo URL
    /// GitHub/Gitea repository url where your project is hosted.
    /// It is used to generate the changelog release link.
    /// It defaults to the url of the default remote.
    pub repo_url: Option<Url>,
    /// # Release Commits
    /// Prepare release only if at least one commit respects this regex.
    pub release_commits: Option<String>,
    /// # Release always
    /// - If true, release-plz release will try to release your packages every time you run it
    ///   (e.g. on every commit in the main branch). *(Default)*.
    /// - If false, `release-plz release` will try release your packages only when you merge the
    ///   release pr.
    ///   Use this if you want to commit your packages and publish them later.
    ///   To determine if a pr is a release-pr, release-plz will check if the branch of the PR starts with
    ///   `release-plz-`. So if you want to create a PR that should trigger a release
    ///   (e.g. when you fix the CI), use this branch name format (e.g. `release-plz-fix-ci`).
    pub release_always: Option<bool>,
}

impl Workspace {
    /// Get the publish timeout. Defaults to 30 minutes.
    pub fn publish_timeout(&self) -> anyhow::Result<Duration> {
        let publish_timeout = self.publish_timeout.as_deref().unwrap_or("30m");
        duration_str::parse(publish_timeout)
            .map_err(|e| anyhow::anyhow!("invalid publish_timeout {publish_timeout}: {e}"))
    }
}

/// Config at the `[[package]]` level.
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone, JsonSchema)]
#[serde(deny_unknown_fields)]
pub struct PackageSpecificConfig {
    /// Configuration that can be specified at the `[workspace]` level, too.
    #[serde(flatten)]
    common: PackageConfig,
    /// # Changelog Include
    /// List of package names.
    /// Include the changelogs of these packages in the changelog of the current package.
    changelog_include: Option<Vec<String>>,
}

impl PackageSpecificConfig {
    /// Merge the package-specific configuration with the global configuration.
    pub fn merge(self, default: PackageConfig) -> PackageSpecificConfig {
        PackageSpecificConfig {
            common: self.common.merge(default),
            changelog_include: self.changelog_include,
        }
    }
}

#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone, JsonSchema)]
pub struct PackageSpecificConfigWithName {
    pub name: String,
    #[serde(flatten)]
    pub config: PackageSpecificConfig,
}

impl From<PackageConfig> for release_plz_core::ReleaseConfig {
    fn from(value: PackageConfig) -> Self {
        let is_publish_enabled = value.publish != Some(false);
        let is_git_release_enabled = value.git_release_enable != Some(false);
        let is_git_release_draft = value.git_release_draft == Some(true);
        let git_release_type: release_plz_core::ReleaseType = value
            .git_release_type
            .map(|release_type| release_type.into())
            .unwrap_or_default();
        let git_release_name = value.git_release_name.clone();
        let git_release_body = value.git_release_body.clone();
        let is_git_tag_enabled = value.git_tag_enable != Some(false);
        let git_tag_name = value.git_tag_name.clone();
        let release = value.release != Some(false);
        let mut cfg = Self::default()
            .with_publish(release_plz_core::PublishConfig::enabled(is_publish_enabled))
            .with_git_release(
                release_plz_core::GitReleaseConfig::enabled(is_git_release_enabled)
                    .set_draft(is_git_release_draft)
                    .set_release_type(git_release_type)
                    .set_name_template(git_release_name)
                    .set_body_template(git_release_body),
            )
            .with_git_tag(
                release_plz_core::GitTagConfig::enabled(is_git_tag_enabled)
                    .set_name_template(git_tag_name),
            )
            .with_release(release);

        if let Some(no_verify) = value.publish_no_verify {
            cfg = cfg.with_no_verify(no_verify);
        }
        if let Some(features) = value.publish_features {
            cfg = cfg.with_features(features);
        }
        if let Some(allow_dirty) = value.publish_allow_dirty {
            cfg = cfg.with_allow_dirty(allow_dirty);
        }
        cfg
    }
}

/// Configuration that can be specified both at the `[workspace]` and at the `[[package]]` level.
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Default, Clone, JsonSchema)]
pub struct PackageConfig {
    /// # Changelog Path
    /// Normally the changelog is placed in the same directory of the Cargo.toml file.
    /// The user can provide a custom path here.
    /// `changelog_path` is propagated to the commands:
    /// `update`, `release-pr` and `release`.
    pub changelog_path: Option<PathBuf>,
    /// # Changelog Update
    /// Whether to create/update changelog or not.
    /// If unspecified, the changelog is updated.
    pub changelog_update: Option<bool>,
    /// # Git Release Enable
    /// Publish the GitHub/Gitea release for the created git tag.
    /// Enabled by default.
    pub git_release_enable: Option<bool>,
    /// # Git Release Body
    /// Tera template of the git release body created by release-plz.
    pub git_release_body: Option<String>,
    /// # Git Release Type
    /// Whether to mark the created release as not ready for production.
    pub git_release_type: Option<ReleaseType>,
    /// # Git Release Draft
    /// If true, will not auto-publish the release.
    pub git_release_draft: Option<bool>,
    /// # Git Release Name
    /// Tera template of the git release name created by release-plz.
    pub git_release_name: Option<String>,
    /// # Git Tag Enable
    /// Publish the git tag for the new package version.
    /// Enabled by default.
    pub git_tag_enable: Option<bool>,
    /// # Git Tag Name
    /// Tera template of the git tag name created by release-plz.
    pub git_tag_name: Option<String>,
    /// # Publish
    /// If `false`, don't run `cargo publish`.
    pub publish: Option<bool>,
    /// # Publish Allow Dirty
    /// If `true`, add the `--allow-dirty` flag to the `cargo publish` command.
    pub publish_allow_dirty: Option<bool>,
    /// # Publish No Verify
    /// If `true`, add the `--no-verify` flag to the `cargo publish` command.
    pub publish_no_verify: Option<bool>,
    /// # Publish Features
    /// If `["a", "b", "c"]`, add the `--features=a,b,c` flag to the `cargo publish` command.
    pub publish_features: Option<Vec<String>>,
    /// # Semver Check
    /// Controls when to run cargo-semver-checks.
    /// If unspecified, run cargo-semver-checks if the package is a library.
    pub semver_check: Option<bool>,
    /// # Release
    /// Used to toggle off the update/release process for a workspace or package.
    pub release: Option<bool>,
}

impl From<PackageConfig> for release_plz_core::UpdateConfig {
    fn from(config: PackageConfig) -> Self {
        Self {
            semver_check: config.semver_check != Some(false),
            changelog_update: config.changelog_update != Some(false),
            release: config.release != Some(false),
            tag_name_template: config.git_tag_name,
            changelog_path: config.changelog_path.map(|p| to_utf8_pathbuf(p).unwrap()),
        }
    }
}

impl From<PackageSpecificConfig> for release_plz_core::PackageUpdateConfig {
    fn from(config: PackageSpecificConfig) -> Self {
        Self {
            generic: config.common.into(),
            changelog_include: config.changelog_include.unwrap_or_default(),
        }
    }
}

impl PackageConfig {
    /// Merge the package-specific configuration with the global configuration.
    pub fn merge(self, default: Self) -> Self {
        Self {
            semver_check: self.semver_check.or(default.semver_check),
            changelog_path: self.changelog_path.or(default.changelog_path),
            changelog_update: self.changelog_update.or(default.changelog_update),
            git_release_enable: self.git_release_enable.or(default.git_release_enable),
            git_release_type: self.git_release_type.or(default.git_release_type),
            git_release_draft: self.git_release_draft.or(default.git_release_draft),
            git_release_name: self.git_release_name.or(default.git_release_name),
            git_release_body: self.git_release_body.or(default.git_release_body),

            publish: self.publish.or(default.publish),
            publish_allow_dirty: self.publish_allow_dirty.or(default.publish_allow_dirty),
            publish_no_verify: self.publish_no_verify.or(default.publish_no_verify),
            publish_features: self.publish_features.or(default.publish_features),
            git_tag_enable: self.git_tag_enable.or(default.git_tag_enable),
            git_tag_name: self.git_tag_name.or(default.git_tag_name),
            release: self.release.or(default.release),
        }
    }

    pub fn changelog_path(&self) -> Option<&Utf8Path> {
        self.changelog_path
            .as_ref()
            .map(|p| to_utf8_path(p.as_ref()).unwrap())
    }
}

/// Whether to run cargo-semver-checks or not.
/// Note: you can only run cargo-semver-checks on a library.
#[derive(Serialize, Deserialize, Default, PartialEq, Eq, Debug, Clone, Copy)]
#[serde(rename_all = "snake_case")]
pub enum SemverCheck {
    /// Run cargo-semver-checks.
    #[default]
    Yes,
    /// Don't run cargo-semver-checks.
    No,
}

#[derive(Serialize, Deserialize, Default, PartialEq, Eq, Debug, Clone, Copy, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ReleaseType {
    /// # Prod
    /// Will mark the release as ready for production.
    #[default]
    Prod,
    /// # Pre
    /// Will mark the release as not ready for production.
    /// I.e. as pre-release.
    Pre,
    /// # Auto
    /// Will mark the release as not ready for production
    /// in case there is a semver pre-release in the tag e.g. v1.0.0-rc1.
    /// Otherwise, will mark the release as ready for production.
    Auto,
}

impl From<ReleaseType> for release_plz_core::ReleaseType {
    fn from(value: ReleaseType) -> Self {
        match value {
            ReleaseType::Prod => Self::Prod,
            ReleaseType::Pre => Self::Pre,
            ReleaseType::Auto => Self::Auto,
        }
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    const BASE_WORKSPACE_CONFIG: &str = r#"
        [workspace]
        dependencies_update = false
        allow_dirty = false
        changelog_config = "../git-cliff.toml"
        repo_url = "https://github.com/MarcoIeni/release-plz"
        git_release_enable = true
        git_release_type = "prod"
        git_release_draft = false
        publish_timeout = "10m"
        release_commits = "^feat:"
    "#;

    const BASE_PACKAGE_CONFIG: &str = r#"
        [[package]]
        name = "crate1"
    "#;

    fn create_base_workspace_config() -> Config {
        Config {
            changelog: ChangelogCfg::default(),
            workspace: Workspace {
                dependencies_update: Some(false),
                changelog_config: Some("../git-cliff.toml".into()),
                allow_dirty: Some(false),
                repo_url: Some("https://github.com/MarcoIeni/release-plz".parse().unwrap()),
                packages_defaults: PackageConfig {
                    semver_check: None,
                    changelog_update: None,
                    git_release_enable: Some(true),
                    git_release_type: Some(ReleaseType::Prod),
                    git_release_draft: Some(false),
                    ..Default::default()
                },
                pr_draft: false,
                pr_labels: vec![],
                publish_timeout: Some("10m".to_string()),
                release_commits: Some("^feat:".to_string()),
                release_always: None,
            },
            package: [].into(),
        }
    }

    fn create_base_package_config() -> PackageSpecificConfigWithName {
        PackageSpecificConfigWithName {
            name: "crate1".to_string(),
            config: PackageSpecificConfig {
                common: PackageConfig {
                    semver_check: None,
                    changelog_update: None,
                    git_release_enable: None,
                    git_release_type: None,
                    git_release_draft: None,
                    ..Default::default()
                },
                changelog_include: None,
            },
        }
    }

    #[test]
    fn config_without_update_config_is_deserialized() {
        let expected_config = create_base_workspace_config();

        let config: Config = toml::from_str(BASE_WORKSPACE_CONFIG).unwrap();
        assert_eq!(config, expected_config);
    }

    #[test]
    fn config_is_deserialized() {
        let config = &format!(
            "{BASE_WORKSPACE_CONFIG}\
            changelog_update = true"
        );

        let mut expected_config = create_base_workspace_config();
        expected_config.workspace.packages_defaults.changelog_update = true.into();

        let config: Config = toml::from_str(config).unwrap();
        assert_eq!(config, expected_config);
    }

    fn config_package_release_is_deserialized(config_flag: &str, expected_value: bool) {
        let config = &format!(
            "{BASE_WORKSPACE_CONFIG}\n{BASE_PACKAGE_CONFIG}\
            release = {config_flag}"
        );

        let mut expected_config = create_base_workspace_config();
        let mut package_config = create_base_package_config();
        package_config.config.common.release = expected_value.into();
        expected_config.package = [package_config].into();

        let config: Config = toml::from_str(config).unwrap();
        assert_eq!(config, expected_config);
    }

    #[test]
    fn config_package_release_is_deserialized_true() {
        config_package_release_is_deserialized("true", true);
    }

    #[test]
    fn config_package_release_is_deserialized_false() {
        config_package_release_is_deserialized("false", false);
    }

    fn config_workspace_release_is_deserialized(config_flag: &str, expected_value: bool) {
        let config = &format!(
            "{BASE_WORKSPACE_CONFIG}\
            release = {config_flag}"
        );

        let mut expected_config = create_base_workspace_config();
        expected_config.workspace.packages_defaults.release = expected_value.into();

        let config: Config = toml::from_str(config).unwrap();
        assert_eq!(config, expected_config);
    }

    #[test]
    fn config_workspace_release_is_deserialized_true() {
        config_workspace_release_is_deserialized("true", true);
    }

    #[test]
    fn config_workspace_release_is_deserialized_false() {
        config_workspace_release_is_deserialized("false", false);
    }

    #[test]
    fn config_is_serialized() {
        let config = Config {
            changelog: ChangelogCfg::default(),
            workspace: Workspace {
                dependencies_update: None,
                changelog_config: Some("../git-cliff.toml".into()),
                allow_dirty: None,
                repo_url: Some("https://github.com/MarcoIeni/release-plz".parse().unwrap()),
                pr_draft: false,
                pr_labels: vec!["label1".to_string()],
                packages_defaults: PackageConfig {
                    semver_check: None,
                    changelog_update: true.into(),
                    git_release_enable: true.into(),
                    git_release_type: Some(ReleaseType::Prod),
                    git_release_draft: Some(false),
                    release: Some(true),
                    changelog_path: Some("./CHANGELOG.md".into()),
                    ..Default::default()
                },
                publish_timeout: Some("10m".to_string()),
                release_commits: Some("^feat:".to_string()),
                release_always: None,
            },
            package: [PackageSpecificConfigWithName {
                name: "crate1".to_string(),
                config: PackageSpecificConfig {
                    common: PackageConfig {
                        semver_check: Some(false),
                        changelog_update: true.into(),
                        git_release_enable: true.into(),
                        git_release_type: Some(ReleaseType::Prod),
                        git_release_draft: Some(false),
                        release: Some(false),
                        ..Default::default()
                    },
                    changelog_include: Some(vec!["pkg1".to_string()]),
                },
            }]
            .into(),
        };

        expect_test::expect![[r#"
            [workspace]
            changelog_path = "./CHANGELOG.md"
            changelog_update = true
            git_release_enable = true
            git_release_type = "prod"
            git_release_draft = false
            release = true
            changelog_config = "../git-cliff.toml"
            pr_draft = false
            pr_labels = ["label1"]
            publish_timeout = "10m"
            repo_url = "https://github.com/MarcoIeni/release-plz"
            release_commits = "^feat:"

            [changelog]

            [[package]]
            name = "crate1"
            changelog_update = true
            git_release_enable = true
            git_release_type = "prod"
            git_release_draft = false
            semver_check = false
            release = false
            changelog_include = ["pkg1"]
        "#]]
        .assert_eq(&toml::to_string(&config).unwrap());
    }

    #[test]
    fn wrong_config_section_is_not_deserialized() {
        let config = "[unknown]";

        let error = toml::from_str::<Config>(config).unwrap_err().to_string();
        expect_test::expect![[r#"
            TOML parse error at line 1, column 2
              |
            1 | [unknown]
              |  ^^^^^^^
            unknown field `unknown`, expected one of `workspace`, `changelog`, `package`
        "#]]
        .assert_eq(&error);
    }

    #[test]
    fn wrong_workspace_section_is_not_deserialized() {
        let config = r#"
[workspace]
unknown = false
allow_dirty = true"#;

        let error = toml::from_str::<Config>(config).unwrap_err().to_string();
        expect_test::expect![[r#"
            TOML parse error at line 2, column 1
              |
            2 | [workspace]
              | ^^^^^^^^^^^
            unknown field `unknown`
        "#]]
        .assert_eq(&error);
    }

    #[test]
    fn wrong_changelog_section_is_not_deserialized() {
        let config = r#"
[changelog]
trim = true
unknown = false"#;

        let error = toml::from_str::<Config>(config).unwrap_err().to_string();
        expect_test::expect![[r#"
            TOML parse error at line 4, column 1
              |
            4 | unknown = false
              | ^^^^^^^
            unknown field `unknown`, expected one of `header`, `body`, `trim`, `commit_preprocessors`, `sort_commits`, `link_parsers`, `commit_parsers`, `protect_breaking_commits`, `tag_pattern`
        "#]]
        .assert_eq(&error);
    }

    #[test]
    fn wrong_package_section_is_not_deserialized() {
        let config = r#"
[[package]]
name = "crate1"
unknown = false"#;

        let error = toml::from_str::<Config>(config).unwrap_err().to_string();
        expect_test::expect![[r#"
            TOML parse error at line 2, column 1
              |
            2 | [[package]]
              | ^^^^^^^^^^^
            unknown field `unknown`
        "#]]
        .assert_eq(&error);
    }
}