-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscheme_test.go
44 lines (31 loc) · 906 Bytes
/
scheme_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
40
41
42
43
44
//go:build generator
package main
import (
"bytes"
"testing"
. "github.com/onsi/gomega"
"github.com/nginx/telemetry-exporter/cmd/generator/tests"
)
func TestGenerateScheme(t *testing.T) {
t.Parallel()
g := NewGomegaWithT(t)
parseCfg := parsingConfig{
pkgName: "tests",
typeName: "Data",
loadPattern: "github.com/nginx/telemetry-exporter/cmd/generator/tests",
buildFlags: []string{"-tags=generator"},
}
_ = tests.Data{} // depends on the type being defined
pResult, err := parse(parseCfg)
g.Expect(err).ToNot(HaveOccurred())
var buf bytes.Buffer
schemeCfg := schemeGenConfig{
namespace: "gateway.nginx.org",
protocol: "avro",
dataFabricDataType: "telemetry",
record: parseCfg.typeName,
fields: pResult.fields,
}
g.Expect(generateScheme(&buf, schemeCfg)).To(Succeed())
g.Expect(buf.Bytes()).ToNot(BeEmpty())
}