Skip to content

Commit b7aec34

Browse files
committed
merge from main
1 parent 737f03e commit b7aec34

2 files changed

Lines changed: 15 additions & 20 deletions

File tree

internal/cmd/generate.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,24 @@ func Generate(ctx context.Context, dir, filename string, o *Options) (map[string
158158
return nil, err
159159
}
160160

161+
return generate(ctx, &sourceFiles{
162+
Config: conf,
163+
ConfigPath: configPath,
164+
Dir: dir,
165+
FileContents: nil,
166+
}, o)
167+
}
168+
169+
// generate runs codegen from in-memory or on-disk inputs (see sourceFiles).
170+
func generate(ctx context.Context, inputs *sourceFiles, o *Options) (map[string]string, error) {
161171
g := &generator{
162-
dir: inputs.Dir,
163-
output: map[string]string{},
172+
dir: inputs.Dir,
173+
output: map[string]string{},
174+
codegenHandlerOverride: o.CodegenHandlerOverride,
164175
}
165-
166-
if err := processQuerySets(ctx, g, inputs, o); err != nil {
176+
if err := processQuerySets(ctx, g, inputs, o); err != nil {
167177
return nil, err
168178
}
169-
170179
return g.output, nil
171180
}
172181

internal/cmd/plugin_engine_test.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
package cmd
22

3-
// Engine-plugin pipeline integration tests.
4-
//
5-
// Why here (cmd) and not in endtoend?
6-
// - endtoend: black-box replay of full sqlc on testdata dirs, comparing stdout/stderr/output to golden files.
7-
// - These tests: unit-style integration of the engine-plugin path inside cmd — in-memory config and FileContents,
8-
// mocks for engine and codegen, no temp dirs or real plugins. They assert the data flow (schema+query → engine
9-
// mock → codegen request) and that the plugin package is used when PluginParseFunc is nil.
10-
//
11-
// Proof that the technology works:
12-
// - TestPluginPipeline_FullPipeline: one block → one Parse call; that call receives schema; codegen gets the result.
13-
// - TestPluginPipeline_NBlocksNCalls: N blocks in query.sql → exactly N Parse calls; each call receives schema.
14-
// - TestPluginPipeline_DatabaseOnly_ReceivesNoSchema: with analyzer.database: only + database.uri, each Parse
15-
// call receives empty schema (the real runner would get connection_params in ParseRequest).
16-
// - TestPluginPipeline_WithoutOverride_UsesPluginPackage: with PluginParseFunc nil, generate fails with an error
17-
// that is NOT "unknown engine", so we did enter runPluginQuerySet and call the engine process runner.
3+
// Integration tests for the engine-plugin path in cmd (in-memory sourceFiles + mocks; no real subprocesses).
184

195
import (
206
"bytes"

0 commit comments

Comments
 (0)