@@ -184,10 +184,10 @@ func TestReportCommand_ReproducibleOutputIsStableAcrossRuns(t *testing.T) {
184184 first := runOnce ()
185185 second := runOnce ()
186186
187- assert .Equal (t , first , second )
187+ assert .Equal (t , stripRawPaths ( t , first ), stripRawPaths ( t , second ) )
188188 assert .NotContains (t , first , `"dateGenerated"` )
189189 assert .NotContains (t , first , `"commitDetails"` )
190- assert .NotContains (t , first , `"rawPath"` )
190+ assert .Contains (t , first , `"rawPath"` )
191191}
192192
193193func TestRunLeftRightReport_GitRefExplodedSpecIncludesSiblingChanges (t * testing.T ) {
@@ -207,8 +207,11 @@ func TestRunLeftRightReport_GitRefExplodedSpecIncludesSiblingChanges(t *testing.
207207
208208 encoded , err := json .Marshal (report )
209209 require .NoError (t , err )
210- assert .Contains (t , string (encoded ), `"property":"required"` )
211- assert .Contains (t , string (encoded ), `"path":"$.paths['/pets'].get.responses['200'].content['application/json'].schema"` )
210+ content := string (encoded )
211+ assert .Contains (t , content , `"property":"required"` )
212+ assert .Contains (t , content , `"path":"$.paths['/pets'].get.responses['200'].content['application/json'].schema"` )
213+ assert .Contains (t , content , `"document":"apis/components/pet.yaml"` )
214+ assert .NotContains (t , content , ".openapi-changes-gitref" )
212215}
213216
214217func TestRunLeftRightReport_LocalExplodedSpecIncludesSiblingChanges (t * testing.T ) {
@@ -282,3 +285,44 @@ func TestReportCommand_GitRefUsesLeftRightMode(t *testing.T) {
282285 assert .Contains (t , output , `"summary"` )
283286 assert .NotContains (t , output , `"reports"` )
284287}
288+
289+ func TestReportCommand_RepoHistoryColonPathUsesHistoryMode (t * testing.T ) {
290+ repoDir := createGitSpecRepoForFile (t , "v1:beta.yaml" )
291+ chdirForTest (t , t .TempDir ())
292+
293+ cmd := testRootCmd (GetReportCommand (), repoDir , "v1:beta.yaml" )
294+ output := captureStdout (t , func () {
295+ require .NoError (t , cmd .Execute ())
296+ })
297+
298+ assert .Contains (t , output , `"gitRepoPath": "` + repoDir + `"` )
299+ assert .Contains (t , output , `"gitFilePath": "v1:beta.yaml"` )
300+ assert .Contains (t , output , `"reports"` )
301+ assert .NotContains (t , output , `"originalPath"` )
302+ }
303+
304+ func stripRawPaths (t * testing.T , raw string ) string {
305+ t .Helper ()
306+
307+ var payload any
308+ require .NoError (t , json .Unmarshal ([]byte (raw ), & payload ))
309+ removeJSONKey (payload , "rawPath" )
310+
311+ bits , err := json .MarshalIndent (payload , "" , " " )
312+ require .NoError (t , err )
313+ return string (bits )
314+ }
315+
316+ func removeJSONKey (value any , key string ) {
317+ switch typed := value .(type ) {
318+ case map [string ]any :
319+ delete (typed , key )
320+ for _ , child := range typed {
321+ removeJSONKey (child , key )
322+ }
323+ case []any :
324+ for _ , child := range typed {
325+ removeJSONKey (child , key )
326+ }
327+ }
328+ }
0 commit comments