-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator_test.go
39 lines (34 loc) · 996 Bytes
/
generator_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package zapmarshaller
import (
"fmt"
"io/ioutil"
"strings"
"testing"
"github.com/mkorolyov/astparser"
. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/reporters"
. "github.com/onsi/gomega"
)
func TestGenerator(t *testing.T) {
RegisterFailHandler(Fail)
junitReporter := reporters.NewJUnitReporter("zap_generator.xml")
RunSpecsWithDefaultAndCustomReporters(t, "ZapGenerator", []Reporter{junitReporter})
}
var _ = Describe("backoff", func() {
It("should generate golden files", func() {
cfg := astparser.Config{
InputDir: "fixtures_test",
IncludeRegexp: "custom.go",
}
sources, err := astparser.Load(cfg)
Ω(err).ShouldNot(HaveOccurred())
generator := Generator{Cfg: Config{}}
files := generator.Generate(sources)
for name, got := range files {
want, err := ioutil.ReadFile(
fmt.Sprintf("fixtures_test/%s.zap.go", strings.Split(name, ".")[0]))
Ω(err).ShouldNot(HaveOccurred())
Ω(string(want)).Should(BeEquivalentTo(string(got)))
}
})
})