MCPcopy
hub / github.com/sqlc-dev/sqlc / TestExamples

Function TestExamples

internal/endtoend/endtoend_test.go:38–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestExamples(t *testing.T) {
39 t.Parallel()
40 ctx := context.Background()
41
42 examples, err := filepath.Abs(filepath.Join("..", "..", "examples"))
43 if err != nil {
44 t.Fatal(err)
45 }
46
47 files, err := os.ReadDir(examples)
48 if err != nil {
49 t.Fatal(err)
50 }
51
52 for _, replay := range files {
53 if !replay.IsDir() {
54 continue
55 }
56 tc := replay.Name()
57 t.Run(tc, func(t *testing.T) {
58 t.Parallel()
59 path := filepath.Join(examples, tc)
60 var stderr bytes.Buffer
61 opts := &cmd.Options{
62 Env: cmd.Env{},
63 Stderr: &stderr,
64 }
65 output, err := cmd.Generate(ctx, path, "", opts)
66 if err != nil {
67 t.Fatalf("sqlc generate failed: %s", stderr.String())
68 }
69 cmpDirectory(t, path, output)
70 })
71 }
72}
73
74func BenchmarkExamples(b *testing.B) {
75 ctx := context.Background()

Callers

nothing calls this directly

Calls 6

GenerateFunction · 0.92
cmpDirectoryFunction · 0.85
AbsMethod · 0.80
NameMethod · 0.65
JoinMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected