|
| 1 | +use crate::utils::Sandbox; |
| 2 | +use crate::utils::setup_metadata; |
| 3 | + |
| 4 | +#[test] |
| 5 | +fn json_shows_paths_as_strings() -> anyhow::Result<()> { |
| 6 | + let env = Sandbox::init_scenario_with_target("two-stacks")?; |
| 7 | + |
| 8 | + // Must set metadata to match the scenario, or else the old APIs used here won't deliver. |
| 9 | + setup_metadata(&env, &["A", "B"])?; |
| 10 | + |
| 11 | + // Create a new file to ensure we have file assignments |
| 12 | + env.file("test-file.txt", "test content"); |
| 13 | + |
| 14 | + env |
| 15 | + .but("--json status") |
| 16 | + .with_assert(env.assert_with_uuid_and_timestamp_redactions()) |
| 17 | + .assert() |
| 18 | + .success() |
| 19 | + .stderr_eq(snapbox::str![]) |
| 20 | + .stdout_eq(snapbox::str![[r#" |
| 21 | +{ |
| 22 | + "stacks": [ |
| 23 | + [ |
| 24 | + null, |
| 25 | + [ |
| 26 | + null, |
| 27 | + [ |
| 28 | + { |
| 29 | + "path": "test-file.txt", |
| 30 | + "assignments": [ |
| 31 | + { |
| 32 | + "id": "[UUID]", |
| 33 | + "hunkHeader": { |
| 34 | + "oldStart": 1, |
| 35 | + "oldLines": 0, |
| 36 | + "newStart": 1, |
| 37 | + "newLines": 1 |
| 38 | + }, |
| 39 | + "path": "test-file.txt", |
| 40 | + "pathBytes": [ |
| 41 | + 116, |
| 42 | + 101, |
| 43 | + 115, |
| 44 | + 116, |
| 45 | + 45, |
| 46 | + 102, |
| 47 | + 105, |
| 48 | + 108, |
| 49 | + 101, |
| 50 | + 46, |
| 51 | + 116, |
| 52 | + 120, |
| 53 | + 116 |
| 54 | + ], |
| 55 | + "stackId": null, |
| 56 | + "lineNumsAdded": [ |
| 57 | + 1 |
| 58 | + ], |
| 59 | + "lineNumsRemoved": [] |
| 60 | + } |
| 61 | + ] |
| 62 | + } |
| 63 | + ] |
| 64 | + ] |
| 65 | + ], |
| 66 | + [ |
| 67 | + "[UUID]", |
| 68 | + [ |
| 69 | + { |
| 70 | + "derivedName": "A", |
| 71 | + "pushStatus": "completelyUnpushed", |
| 72 | + "branchDetails": [ |
| 73 | + { |
| 74 | + "name": "A", |
| 75 | + "remoteTrackingBranch": null, |
| 76 | + "description": null, |
| 77 | + "prNumber": null, |
| 78 | + "reviewId": null, |
| 79 | + "tip": "9477ae721ab521d9d0174f70e804ce3ff9f6fb56", |
| 80 | + "baseCommit": "0dc37334a458df421bf67ea806103bf5004845dd", |
| 81 | + "pushStatus": "completelyUnpushed", |
| 82 | + "lastUpdatedAt": [TIMESTAMP], |
| 83 | + "authors": [ |
| 84 | + { |
| 85 | + "name": "author", |
| 86 | + |
| 87 | + "gravatarUrl": "https://www.gravatar.com/avatar/5c1e6d6e64e12aca17657581a48005d1?s=100&r=g&d=retro" |
| 88 | + } |
| 89 | + ], |
| 90 | + "isConflicted": false, |
| 91 | + "commits": [ |
| 92 | + { |
| 93 | + "id": "9477ae721ab521d9d0174f70e804ce3ff9f6fb56", |
| 94 | + "parentIds": [ |
| 95 | + "0dc37334a458df421bf67ea806103bf5004845dd" |
| 96 | + ], |
| 97 | + "message": "add A/n", |
| 98 | + "hasConflicts": false, |
| 99 | + "state": { |
| 100 | + "type": "LocalOnly" |
| 101 | + }, |
| 102 | + "createdAt": 946684800000, |
| 103 | + "author": { |
| 104 | + "name": "author", |
| 105 | + |
| 106 | + "gravatarUrl": "https://www.gravatar.com/avatar/5c1e6d6e64e12aca17657581a48005d1?s=100&r=g&d=retro" |
| 107 | + }, |
| 108 | + "gerritReviewUrl": null |
| 109 | + } |
| 110 | + ], |
| 111 | + "upstreamCommits": [], |
| 112 | + "isRemoteHead": false |
| 113 | + } |
| 114 | + ], |
| 115 | + "isConflicted": false |
| 116 | + }, |
| 117 | + [] |
| 118 | + ] |
| 119 | + ], |
| 120 | + [ |
| 121 | + "[UUID]", |
| 122 | + [ |
| 123 | + { |
| 124 | + "derivedName": "B", |
| 125 | + "pushStatus": "completelyUnpushed", |
| 126 | + "branchDetails": [ |
| 127 | + { |
| 128 | + "name": "B", |
| 129 | + "remoteTrackingBranch": null, |
| 130 | + "description": null, |
| 131 | + "prNumber": null, |
| 132 | + "reviewId": null, |
| 133 | + "tip": "d3e2ba36c529fbdce8de90593e22aceae21f9b17", |
| 134 | + "baseCommit": "0dc37334a458df421bf67ea806103bf5004845dd", |
| 135 | + "pushStatus": "completelyUnpushed", |
| 136 | + "lastUpdatedAt": [TIMESTAMP], |
| 137 | + "authors": [ |
| 138 | + { |
| 139 | + "name": "author", |
| 140 | + |
| 141 | + "gravatarUrl": "https://www.gravatar.com/avatar/5c1e6d6e64e12aca17657581a48005d1?s=100&r=g&d=retro" |
| 142 | + } |
| 143 | + ], |
| 144 | + "isConflicted": false, |
| 145 | + "commits": [ |
| 146 | + { |
| 147 | + "id": "d3e2ba36c529fbdce8de90593e22aceae21f9b17", |
| 148 | + "parentIds": [ |
| 149 | + "0dc37334a458df421bf67ea806103bf5004845dd" |
| 150 | + ], |
| 151 | + "message": "add B/n", |
| 152 | + "hasConflicts": false, |
| 153 | + "state": { |
| 154 | + "type": "LocalOnly" |
| 155 | + }, |
| 156 | + "createdAt": 946684800000, |
| 157 | + "author": { |
| 158 | + "name": "author", |
| 159 | + |
| 160 | + "gravatarUrl": "https://www.gravatar.com/avatar/5c1e6d6e64e12aca17657581a48005d1?s=100&r=g&d=retro" |
| 161 | + }, |
| 162 | + "gerritReviewUrl": null |
| 163 | + } |
| 164 | + ], |
| 165 | + "upstreamCommits": [], |
| 166 | + "isRemoteHead": false |
| 167 | + } |
| 168 | + ], |
| 169 | + "isConflicted": false |
| 170 | + }, |
| 171 | + [] |
| 172 | + ] |
| 173 | + ] |
| 174 | + ], |
| 175 | + "common_merge_base": { |
| 176 | + "target_name": "origin/main", |
| 177 | + "common_merge_base": "0dc3733", |
| 178 | + "message": "add M " |
| 179 | + } |
| 180 | +} |
| 181 | +
|
| 182 | +"#]]); |
| 183 | + |
| 184 | + Ok(()) |
| 185 | +} |
0 commit comments