Skip to content

Commit

Permalink
increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
amyangfei committed May 2, 2019
1 parent 1b28c61 commit 215e17a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/hello/hello.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ func setCode(i *int, val int) {

func Hello() int {
var i int
if func(v *int) {
if j := func(v *int) int {
failpoint.Inject("IfCondInject", func() {
fmt.Println("set code inject in if condition")
setCode(&i, success)
})
}(&i); i != success {
failpoint.Inject("IfCondInject", func() {
return *v
}(&i); j != success {
failpoint.Inject("IfBodyInject", func() {
fmt.Println("set code inject in if body")
})
setCode(&i, success2)
Expand Down
5 changes: 5 additions & 0 deletions pkg/hello/hello_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ func TestHello(t *testing.T) {
failpoint.Enable("github.com/amyangfei/fpcov/pkg/hello/IfCondInject", "return(true)")
val := Hello()
assert.Equal(t, val, success)

failpoint.Disable("github.com/amyangfei/fpcov/pkg/hello/IfCondInject")
failpoint.Enable("github.com/amyangfei/fpcov/pkg/hello/IfBodyInject", "return(true)")
val = Hello()
assert.Equal(t, val, success2)
}

func TestShake(t *testing.T) {
Expand Down

0 comments on commit 215e17a

Please sign in to comment.