Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/cli/compile_compiler_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@
package cli

import (
"reflect"
"testing"

"github.com/github/gh-aw/pkg/workflow"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage for DisableModelsDevLookup branch is now zero: the two removed tests were the only safety net verifying that createAndConfigureCompiler wires (or skips) SetModelPricingResolver based on DisableModelsDevLookup.

💡 Why this matters and suggested fix

The conditional at compile_compiler_setup.go:119-125:

if config.DisableModelsDevLookup {
    // no resolver registered
} else {
    compiler.SetModelPricingResolver(FindOrFetchModelPricing)
}

...is now completely untested at the CLI setup level. If the condition is accidentally inverted, the else branch dropped, or the wrong resolver wired in a future refactor, nothing will catch it.

Options:

  1. Keep a package-internal (unexported) helper instead of deleting the method entirely:
// in compiler_types.go — unexported, tests-only visibility via same package
func (c *Compiler) hasModelPricingResolver() bool {
    return c.modelPricingResolver != nil
}
  1. Replace the deleted tests with ones that inspect resolver behaviour indirectly (compile a minimal workflow that needs pricing and assert the resolver is/isn't called).
  2. At minimum, add a comment in the test file noting that this branch is intentionally not covered at the unit level.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 8c41a0a with restored CLI setup tests, and documented the remaining reflective coupling note in 0a49da8. The DisableModelsDevLookup branch now has explicit test coverage again.

)

func hasModelPricingResolver(compiler *workflow.Compiler) bool {
// Keep this field name in sync with workflow.Compiler; this helper intentionally
// inspects private state to preserve behavioral coverage without re-exporting API.
return !reflect.ValueOf(compiler).Elem().FieldByName("modelPricingResolver").IsNil()
}

func TestCreateAndConfigureCompiler_RegistersModelPricingResolverByDefault(t *testing.T) {
compiler := createAndConfigureCompiler(CompileConfig{})
if !compiler.HasModelPricingResolver() {
if !hasModelPricingResolver(compiler) {
t.Fatal("expected model pricing resolver to be registered by default")
}
}

func TestCreateAndConfigureCompiler_SkipsModelPricingResolverWhenDisabled(t *testing.T) {
compiler := createAndConfigureCompiler(CompileConfig{DisableModelsDevLookup: true})
if compiler.HasModelPricingResolver() {
if hasModelPricingResolver(compiler) {
t.Fatal("expected model pricing resolver to be nil when models.dev lookup is disabled")
}
}
Expand Down
5 changes: 0 additions & 5 deletions pkg/workflow/compiler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ func (c *Compiler) SetModelPricingResolver(fn func(ctx context.Context, provider
c.modelPricingResolver = fn
}

// HasModelPricingResolver reports whether a model pricing resolver callback is configured.
func (c *Compiler) HasModelPricingResolver() bool {
return c.modelPricingResolver != nil
}

// SetRequireDocker configures whether Docker must be available for container image validation.
// When true, validation fails with an error if Docker is not installed or the daemon is not running.
// When false (default), validation is silently skipped when Docker is unavailable.
Expand Down
Loading