chore: more comments and a test rename
diff --git a/internal/librariangen/configure/configure.go b/internal/librariangen/configure/configure.go index f0033cd..6213577 100644 --- a/internal/librariangen/configure/configure.go +++ b/internal/librariangen/configure/configure.go
@@ -145,6 +145,9 @@ return nil } +// findLibraryAndAPIToConfigure examines a request, and finds a single library +// containing a single new API, returning both of them. An error is returned +// if there is not exactly one library containing exactly one new API. func findLibraryAndAPIToConfigure(req *Request) (*request.Library, *request.API, error) { var library *request.Library var api *request.API @@ -314,6 +317,10 @@ return execvRun(ctx, args, moduleDir) } +// goModEditReplaceInSnippets copies internal/generated/snippets/go.mod from +// cfg.RepoDir to cfg.OutputDir, then runs go mod edit to replace the specified +// modulePath with relativeDir which is expected to the location of the module +// relative to internal/generated/snippets func goModEditReplaceInSnippets(ctx context.Context, cfg *Config, modulePath, relativeDir string) error { outputSnippetsDir := filepath.Join(cfg.OutputDir, "internal", "generated", "snippets") if err := os.MkdirAll(outputSnippetsDir, 0755); err != nil { @@ -324,6 +331,8 @@ return execvRun(ctx, args, outputSnippetsDir) } +// copyRepoFileToOutput copies a single file (identified via path) +// from cfg.RepoDir to cfg.OutputDir. func copyRepoFileToOutput(cfg *Config, path string) error { src := filepath.Join(cfg.RepoDir, path) dst := filepath.Join(cfg.OutputDir, path)
diff --git a/internal/librariangen/configure/configure_test.go b/internal/librariangen/configure/configure_test.go index d7aea41..c4baa30 100644 --- a/internal/librariangen/configure/configure_test.go +++ b/internal/librariangen/configure/configure_test.go
@@ -97,7 +97,7 @@ } } -func TestFindLibraryToConfigure(t *testing.T) { +func TestFindLibraryAndAPIToConfigure(t *testing.T) { tests := []struct { name string req *Request