|
| 1 | +use assert_fs::prelude::*; |
| 2 | + |
| 3 | +use crate::{common::TestContext, seal_snapshot}; |
| 4 | + |
| 5 | +#[test] |
| 6 | +fn bump_no_changelog_changes_when_no_changelog_option() { |
| 7 | + let context = TestContext::new(); |
| 8 | + context.seal_toml( |
| 9 | + r#" |
| 10 | +[release] |
| 11 | +current-version = "1.0.0" |
| 12 | +version-files = ["Cargo.toml"] |
| 13 | +commit-message = "Release v{version}" |
| 14 | +branch-name = "release/v{version}" |
| 15 | +push = false |
| 16 | +create-pr = false |
| 17 | +confirm = false |
| 18 | +
|
| 19 | +[changelog] |
| 20 | +ignore-labels = ["internal", "ci"] |
| 21 | +"#, |
| 22 | + ); |
| 23 | + context.init_git(); |
| 24 | + |
| 25 | + context |
| 26 | + .root |
| 27 | + .child("Cargo.toml") |
| 28 | + .write_str( |
| 29 | + r#"[package] |
| 30 | +name = "test" |
| 31 | +version = "1.0.0" |
| 32 | +"#, |
| 33 | + ) |
| 34 | + .unwrap(); |
| 35 | + |
| 36 | + seal_snapshot!(context.filters(), context.command().arg("bump").arg("patch").arg("--no-changelog"), @r#" |
| 37 | + success: true |
| 38 | + exit_code: 0 |
| 39 | + ----- stdout ----- |
| 40 | + Bumping version from 1.0.0 to 1.0.1 |
| 41 | +
|
| 42 | + Preview of changes: |
| 43 | + ------------------- |
| 44 | +
|
| 45 | + diff --git a[TEMP]/Cargo.toml b[TEMP]/Cargo.toml |
| 46 | + --- a[TEMP]/Cargo.toml |
| 47 | + +++ b[TEMP]/Cargo.toml |
| 48 | + @@ -1,3 +1,3 @@ |
| 49 | + [package] |
| 50 | + name = "test" |
| 51 | + -version = "1.0.0" |
| 52 | + +version = "1.0.1" |
| 53 | +
|
| 54 | + diff --git a[TEMP]/seal.toml b[TEMP]/seal.toml |
| 55 | + --- a[TEMP]/seal.toml |
| 56 | + +++ b[TEMP]/seal.toml |
| 57 | + @@ -1,5 +1,5 @@ |
| 58 | + [release] |
| 59 | + -current-version = "1.0.0" |
| 60 | + +current-version = "1.0.1" |
| 61 | + version-files = ["Cargo.toml"] |
| 62 | + commit-message = "Release v{version}" |
| 63 | + branch-name = "release/v{version}" |
| 64 | + Skipping changelog update because `--no-changelog` was provided. |
| 65 | +
|
| 66 | + Changes to be made: |
| 67 | + - Update `[TEMP]/Cargo.toml` |
| 68 | + - Update `[TEMP]/seal.toml` |
| 69 | +
|
| 70 | + Commands to be executed: |
| 71 | + `git checkout -b release/v1.0.1` |
| 72 | + `git add -A` |
| 73 | + `git commit -m "Release v1.0.1"` |
| 74 | +
|
| 75 | + Creating branch: release/v1.0.1 |
| 76 | + Updating version files... |
| 77 | + Committing changes... |
| 78 | + Successfully bumped to 1.0.1 |
| 79 | +
|
| 80 | + ----- stderr ----- |
| 81 | + "#); |
| 82 | +} |
| 83 | + |
| 84 | +#[test] |
| 85 | +fn bump_without_changelog_skips_generation() { |
| 86 | + let context = TestContext::new(); |
| 87 | + context.seal_toml( |
| 88 | + r#" |
| 89 | +[release] |
| 90 | +current-version = "1.0.0" |
| 91 | +version-files = ["Cargo.toml"] |
| 92 | +confirm = false |
| 93 | +"#, |
| 94 | + ); |
| 95 | + context.init_git(); |
| 96 | + |
| 97 | + context |
| 98 | + .root |
| 99 | + .child("Cargo.toml") |
| 100 | + .write_str( |
| 101 | + r#"[package] |
| 102 | +name = "test" |
| 103 | +version = "1.0.0" |
| 104 | +"#, |
| 105 | + ) |
| 106 | + .unwrap(); |
| 107 | + |
| 108 | + seal_snapshot!(context.filters(), context.command().arg("bump").arg("patch"), @r#" |
| 109 | + success: true |
| 110 | + exit_code: 0 |
| 111 | + ----- stdout ----- |
| 112 | + Bumping version from 1.0.0 to 1.0.1 |
| 113 | +
|
| 114 | + Preview of changes: |
| 115 | + ------------------- |
| 116 | +
|
| 117 | + diff --git a[TEMP]/Cargo.toml b[TEMP]/Cargo.toml |
| 118 | + --- a[TEMP]/Cargo.toml |
| 119 | + +++ b[TEMP]/Cargo.toml |
| 120 | + @@ -1,3 +1,3 @@ |
| 121 | + [package] |
| 122 | + name = "test" |
| 123 | + -version = "1.0.0" |
| 124 | + +version = "1.0.1" |
| 125 | +
|
| 126 | + diff --git a[TEMP]/seal.toml b[TEMP]/seal.toml |
| 127 | + --- a[TEMP]/seal.toml |
| 128 | + +++ b[TEMP]/seal.toml |
| 129 | + @@ -1,4 +1,4 @@ |
| 130 | + [release] |
| 131 | + -current-version = "1.0.0" |
| 132 | + +current-version = "1.0.1" |
| 133 | + version-files = ["Cargo.toml"] |
| 134 | + confirm = false |
| 135 | + Skipping changelog update because no `[changelog]` section was found in the configuration. |
| 136 | +
|
| 137 | + Changes to be made: |
| 138 | + - Update `[TEMP]/Cargo.toml` |
| 139 | + - Update `[TEMP]/seal.toml` |
| 140 | +
|
| 141 | + Note: No branch or commit will be created (branch-name and commit-message not configured) |
| 142 | +
|
| 143 | + Updating version files... |
| 144 | + Successfully bumped to 1.0.1 |
| 145 | + Note: No git branch or commit was created |
| 146 | +
|
| 147 | + ----- stderr ----- |
| 148 | + "#); |
| 149 | +} |
0 commit comments