Skip to content

Commit

Permalink
Merge pull request #90 from homeport/fix/issue-89
Browse files Browse the repository at this point in the history
Fix indention issue in type change output
  • Loading branch information
HeavyWombat authored Jan 29, 2020
2 parents cea8ab3 + d7467a9 commit 131c6d0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
14 changes: 14 additions & 0 deletions assets/issues/issue-89/expected-dyff-spruce.human
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

foo
± type change from map to list
- a: 1
b: 2
+ - 1
- 2

bar
± type change from map to <nil>
- c: 3
d: 4
+ <nil>

7 changes: 7 additions & 0 deletions assets/issues/issue-89/from.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
foo:
a: 1
b: 2
bar:
c: 3
d: 4
5 changes: 5 additions & 0 deletions assets/issues/issue-89/to.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
foo:
- 1
- 2
bar:
4 changes: 2 additions & 2 deletions pkg/dyff/output_human.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ func (report *HumanReport) generateHumanDetailOutputModification(detail Detail)
return "", err
}

output.WriteString(red(" - %v\n", strings.TrimRight(from, "\n")))
output.WriteString(green(" + %v\n", strings.TrimRight(to, "\n")))
output.WriteString(red("%s", createStringWithPrefix(" - ", strings.TrimRight(from, "\n"))))
output.WriteString(green("%s", createStringWithPrefix(" + ", strings.TrimRight(to, "\n"))))
}

return output.String(), nil
Expand Down
19 changes: 19 additions & 0 deletions pkg/dyff/output_human_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,23 @@ variables.ROUTER_TLS_PEM.options
`)))
})
})

Context("reported output issues", func() {
BeforeEach(func() {
ColorSetting = OFF
TrueColorSetting = OFF
})

AfterEach(func() {
ColorSetting = AUTO
TrueColorSetting = AUTO
})

It("should use correct indentions for all kind of changes", func() {
compareAgainstExpected("../../assets/issues/issue-89/from.yml",
"../../assets/issues/issue-89/to.yml",
"../../assets/issues/issue-89/expected-dyff-spruce.human",
false)
})
})
})

0 comments on commit 131c6d0

Please sign in to comment.