Skip to content

Commit

Permalink
fix build for go 1.10 and go 1.11, add build and coverage badges
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Jun 24, 2019
1 parent 5efe1fc commit 90b18da
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ language: go
go:
- master
- 1.x
- 1.8.x
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
>
> Simple, lightweight tracing mechanism.
[![Build][icon_build]][page_build]
[![Coverage][icon_coverage]][page_coverage]
[![Documentation][icon_docs]][page_docs]

## 💡 Idea
Expand Down Expand Up @@ -97,9 +99,11 @@ $ go get -u github.com/kamilsk/tracer
made with ❤️ for everyone

[icon_build]: https://travis-ci.org/kamilsk/tracer.svg?branch=master
[icon_coverage]: https://api.codeclimate.com/v1/badges/fb66449d1f5c64542377/test_coverage
[icon_docs]: https://godoc.org/github.com/kamilsk/tracer?status.svg

[page_build]: https://travis-ci.org/kamilsk/tracer
[page_coverage]: https://codeclimate.com/github/kamilsk/tracer/test_coverage
[page_docs]: https://godoc.org/github.com/kamilsk/tracer
[page_promo]: https://github.com/kamilsk/tracer

Expand Down
25 changes: 18 additions & 7 deletions caller_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tracer_test

import (
"reflect"
"strings"
"testing"

. "github.com/kamilsk/tracer"
Expand All @@ -11,17 +11,28 @@ func TestCaller(t *testing.T) {
tests := []struct {
name string
caller func() CallerInfo
expected string
expected []string
}{
{"direct caller", callerA, "github.com/kamilsk/tracer_test.callerA"},
{"chain caller", callerB, "github.com/kamilsk/tracer_test.callerA"},
{"lambda caller", callerC, "github.com/kamilsk/tracer_test.callerC"},
{"direct caller", callerA, []string{"github.com/kamilsk/tracer_test.callerA"}},
{"chain caller", callerB, []string{"github.com/kamilsk/tracer_test.callerA"}},
{"lambda caller", callerC, []string{
"github.com/kamilsk/tracer_test.callerC",
"github.com/kamilsk/tracer_test.callerC.func1", // Go 1.10, 1.11 - https://golang.org/doc/go1.12#runtime
}},
}
for _, test := range tests {
tc := test
t.Run(test.name, func(t *testing.T) {
if expected, obtained := tc.expected, tc.caller().Name; !reflect.DeepEqual(tc.expected, obtained) {
t.Errorf("\n expected: %+#v \n obtained: %+#v", expected, obtained)
var found bool
obtained := tc.caller().Name
for _, expected := range tc.expected {
if expected == obtained {
found = true
break
}
}
if !found {
t.Errorf("\n expected: %+#v \n obtained: %+#v", strings.Join(tc.expected, " or "), obtained)
}
})
}
Expand Down

0 comments on commit 90b18da

Please sign in to comment.