Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a4e2857
Initial plan
Copilot Jul 7, 2025
8607990
Implement verbose configuration debugging functionality
Copilot Jul 7, 2025
9059f53
Fix linter errors and add comprehensive test coverage for VerboseEnvF…
Copilot Jul 7, 2025
d82bb02
Fix CI failures: format code, fix example module names, add missing c…
Copilot Jul 7, 2025
03bc589
Fix CI failures and improve test coverage for verbose configuration d…
Copilot Jul 8, 2025
6ff88d6
Merge branch 'main' into copilot/fix-21
intel352 Jul 8, 2025
8d0ad7e
Merge branch 'main' into copilot/fix-21
intel352 Jul 8, 2025
152423d
Fix linting errors: format code and use require.Error for error asser…
Copilot Jul 8, 2025
3e4585d
Fix verbose-debug example to work correctly with instance-aware confi…
Copilot Jul 8, 2025
317b9fc
Fix verbose-debug example: working SQLite driver and correct exit code
Copilot Jul 8, 2025
9dd0d2e
Add comprehensive test coverage for verbose configuration debugging a…
Copilot Jul 8, 2025
ef056d3
Improve test coverage for config provider functions to 74.9% total co…
Copilot Jul 8, 2025
6c99ec1
Fix verbose-debug example build failure by removing corrupted main_ol…
Copilot Jul 8, 2025
adcd954
Fix linting errors and CI example failures
Copilot Jul 8, 2025
52b0424
Extend verbose logging to all feeders and fix CI example issues
Copilot Jul 8, 2025
986db54
Fixing more linter errors
intel352 Jul 8, 2025
50aa5fd
Improving test coverage
intel352 Jul 8, 2025
a4a8eb9
Fixing linter error and ensuring local dependency
intel352 Jul 8, 2025
477138e
Fixing interface matching and a failing test mock
intel352 Jul 8, 2025
51e9b9d
Add comprehensive tests for debug commands in modcli
intel352 Jul 8, 2025
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
36 changes: 34 additions & 2 deletions .github/workflows/cli-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,41 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

test:
name: Run CLI Tests
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
check-latest: true
cache: true

- name: Get dependencies
run: |
cd cmd/modcli
go mod download
go mod verify

- name: Run CLI tests
run: |
cd cmd/modcli
go test ./... -v -race

- name: Run lint checks
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
cd cmd/modcli
golangci-lint run

build:
name: Build CLI
needs: prepare
needs: [prepare, test]
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -151,7 +183,7 @@ jobs:
release:
name: Create Release
runs-on: ubuntu-latest
needs: [prepare, build]
needs: [prepare, test, build]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/examples-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
- http-client
- advanced-logging
- multi-tenant-app
- instance-aware-db
- verbose-debug
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down Expand Up @@ -98,7 +100,7 @@ jobs:

kill $PID 2>/dev/null || true

elif [ "${{ matrix.example }}" = "reverse-proxy" ] || [ "${{ matrix.example }}" = "http-client" ] || [ "${{ matrix.example }}" = "advanced-logging" ] || [ "${{ matrix.example }}" = "multi-tenant-app" ]; then
elif [ "${{ matrix.example }}" = "reverse-proxy" ] || [ "${{ matrix.example }}" = "http-client" ] || [ "${{ matrix.example }}" = "advanced-logging" ] || [ "${{ matrix.example }}" = "multi-tenant-app" ] || [ "${{ matrix.example }}" = "verbose-debug" ] || [ "${{ matrix.example }}" = "instance-aware-db" ]; then
# These apps just need to start without immediate errors
timeout 5s ./example &
PID=$!
Expand Down
27 changes: 26 additions & 1 deletion application.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ type Application interface {
// Should be called before module registration to ensure
// all framework operations use the new logger.
SetLogger(logger Logger)

// SetVerboseConfig enables or disables verbose configuration debugging.
// When enabled, DEBUG level logging will be performed during configuration
// processing to show which config is being processed, which key is being
// evaluated, and which attribute or key is being searched for.
SetVerboseConfig(enabled bool)

// IsVerboseConfig returns whether verbose configuration debugging is enabled.
IsVerboseConfig() bool
}

// TenantApplication extends Application with multi-tenant functionality.
Expand Down Expand Up @@ -229,6 +238,7 @@ type StdApplication struct {
ctx context.Context
cancel context.CancelFunc
tenantService TenantService // Added tenant service reference
verboseConfig bool // Flag for verbose configuration debugging
}

// NewStdApplication creates a new application instance with the provided configuration and logger.
Expand Down Expand Up @@ -665,7 +675,7 @@ func (app *StdApplication) resolveInterfaceBasedDependencies(
func (app *StdApplication) findServiceByInterface(dep ServiceDependency) (service any, serviceName string) {
for serviceName, service := range app.svcRegistry {
serviceType := reflect.TypeOf(service)
if serviceType.Implements(dep.SatisfiesInterface) {
if app.typeImplementsInterface(serviceType, dep.SatisfiesInterface) {
return service, serviceName
}
}
Expand Down Expand Up @@ -815,6 +825,21 @@ func (app *StdApplication) SetLogger(logger Logger) {
app.logger = logger
}

// SetVerboseConfig enables or disables verbose configuration debugging
func (app *StdApplication) SetVerboseConfig(enabled bool) {
app.verboseConfig = enabled
if enabled {
app.logger.Debug("Verbose configuration debugging enabled")
} else {
app.logger.Debug("Verbose configuration debugging disabled")
}
}

// IsVerboseConfig returns whether verbose configuration debugging is enabled
func (app *StdApplication) IsVerboseConfig() bool {
return app.verboseConfig
}

// resolveDependencies returns modules in initialization order
func (app *StdApplication) resolveDependencies() ([]string, error) {
// Create dependency graph
Expand Down
83 changes: 83 additions & 0 deletions application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -842,3 +842,86 @@ var (
ErrModuleStartFailed = fmt.Errorf("module start failed")
ErrModuleStopFailed = fmt.Errorf("module stop failed")
)

func TestSetVerboseConfig(t *testing.T) {
tests := []struct {
name string
enabled bool
}{
{
name: "Enable verbose config",
enabled: true,
},
{
name: "Disable verbose config",
enabled: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
// Create a mock logger to capture debug messages
mockLogger := &MockLogger{}

// Set up expectations for debug messages
if tt.enabled {
mockLogger.On("Debug", "Verbose configuration debugging enabled", []interface{}(nil)).Return()
} else {
mockLogger.On("Debug", "Verbose configuration debugging disabled", []interface{}(nil)).Return()
}

// Create application with mock logger
app := NewStdApplication(
NewStdConfigProvider(testCfg{Str: "test"}),
mockLogger,
)

// Test that verbose config is initially false
if app.IsVerboseConfig() != false {
t.Error("Expected verbose config to be initially false")
}

// Set verbose config
app.SetVerboseConfig(tt.enabled)

// Verify the setting was applied
if app.IsVerboseConfig() != tt.enabled {
t.Errorf("Expected verbose config to be %v, got %v", tt.enabled, app.IsVerboseConfig())
}

// Verify mock expectations were met
mockLogger.AssertExpectations(t)
})
}
}

func TestIsVerboseConfig(t *testing.T) {
mockLogger := &MockLogger{}

// Create application
app := NewStdApplication(
NewStdConfigProvider(testCfg{Str: "test"}),
mockLogger,
)

// Test initial state
if app.IsVerboseConfig() != false {
t.Error("Expected IsVerboseConfig to return false initially")
}

// Test after enabling
mockLogger.On("Debug", "Verbose configuration debugging enabled", []interface{}(nil)).Return()
app.SetVerboseConfig(true)
if app.IsVerboseConfig() != true {
t.Error("Expected IsVerboseConfig to return true after enabling")
}

// Test after disabling
mockLogger.On("Debug", "Verbose configuration debugging disabled", []interface{}(nil)).Return()
app.SetVerboseConfig(false)
if app.IsVerboseConfig() != false {
t.Error("Expected IsVerboseConfig to return false after disabling")
}

mockLogger.AssertExpectations(t)
}
Loading