fix: resolve variable shadowing in test files (core → framework alias)

Local variable `core` shadowed the package import `core`, causing
`core.ServiceFor` to be interpreted as a method call instead of a
package-level function. Aliased import as `framework`.

Also fixes pre-existing compilation failure in go-process test suite.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Snider 2026-03-09 13:58:18 +00:00
parent 7ea523ee7b
commit 4c17be4e46
3 changed files with 27 additions and 27 deletions

View file

@ -5,7 +5,7 @@ import (
"sync"
"testing"
"forge.lthn.ai/core/go/pkg/core"
framework "forge.lthn.ai/core/go/pkg/core"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -53,12 +53,12 @@ func TestGlobal_SetDefault(t *testing.T) {
}
}()
core, err := core.New(
core.WithName("process", NewService(Options{})),
c, err := framework.New(
framework.WithName("process", NewService(Options{})),
)
require.NoError(t, err)
svc, err := core.ServiceFor[*Service](core, "process")
svc, err := framework.ServiceFor[*Service](c, "process")
require.NoError(t, err)
SetDefault(svc)
@ -81,12 +81,12 @@ func TestGlobal_ConcurrentDefault(t *testing.T) {
}
}()
core, err := core.New(
core.WithName("process", NewService(Options{})),
c, err := framework.New(
framework.WithName("process", NewService(Options{})),
)
require.NoError(t, err)
svc, err := core.ServiceFor[*Service](core, "process")
svc, err := framework.ServiceFor[*Service](c, "process")
require.NoError(t, err)
SetDefault(svc)
@ -117,12 +117,12 @@ func TestGlobal_ConcurrentSetDefault(t *testing.T) {
// Create multiple services
var services []*Service
for i := 0; i < 10; i++ {
core, err := core.New(
core.WithName("process", NewService(Options{})),
c, err := framework.New(
framework.WithName("process", NewService(Options{})),
)
require.NoError(t, err)
svc, err := core.ServiceFor[*Service](core, "process")
svc, err := framework.ServiceFor[*Service](c, "process")
require.NoError(t, err)
services = append(services, svc)
}
@ -161,12 +161,12 @@ func TestGlobal_ConcurrentOperations(t *testing.T) {
}
}()
core, err := core.New(
core.WithName("process", NewService(Options{})),
c, err := framework.New(
framework.WithName("process", NewService(Options{})),
)
require.NoError(t, err)
svc, err := core.ServiceFor[*Service](core, "process")
svc, err := framework.ServiceFor[*Service](c, "process")
require.NoError(t, err)
SetDefault(svc)

View file

@ -4,7 +4,7 @@ import (
"context"
"testing"
"forge.lthn.ai/core/go/pkg/core"
framework "forge.lthn.ai/core/go/pkg/core"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
@ -12,12 +12,12 @@ import (
func newTestRunner(t *testing.T) *Runner {
t.Helper()
core, err := core.New(
core.WithName("process", NewService(Options{})),
c, err := framework.New(
framework.WithName("process", NewService(Options{})),
)
require.NoError(t, err)
svc, err := core.ServiceFor[*Service](core, "process")
svc, err := framework.ServiceFor[*Service](c, "process")
require.NoError(t, err)
return NewRunner(svc)

View file

@ -7,23 +7,23 @@ import (
"testing"
"time"
"forge.lthn.ai/core/go/pkg/core"
framework "forge.lthn.ai/core/go/pkg/core"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func newTestService(t *testing.T) (*Service, *core.Core) {
func newTestService(t *testing.T) (*Service, *framework.Core) {
t.Helper()
core, err := core.New(
core.WithName("process", NewService(Options{BufferSize: 1024})),
c, err := framework.New(
framework.WithName("process", NewService(Options{BufferSize: 1024})),
)
require.NoError(t, err)
svc, err := core.ServiceFor[*Service](core, "process")
svc, err := framework.ServiceFor[*Service](c, "process")
require.NoError(t, err)
return svc, core
return svc, c
}
func TestService_Start(t *testing.T) {
@ -120,8 +120,8 @@ func TestService_Run(t *testing.T) {
func TestService_Actions(t *testing.T) {
t.Run("broadcasts events", func(t *testing.T) {
core, err := core.New(
core.WithName("process", NewService(Options{})),
c, err := framework.New(
framework.WithName("process", NewService(Options{})),
)
require.NoError(t, err)
@ -130,7 +130,7 @@ func TestService_Actions(t *testing.T) {
var exited []ActionProcessExited
var mu sync.Mutex
core.RegisterAction(func(c *core.Core, msg core.Message) error {
c.RegisterAction(func(cc *framework.Core, msg framework.Message) error {
mu.Lock()
defer mu.Unlock()
switch m := msg.(type) {
@ -144,7 +144,7 @@ func TestService_Actions(t *testing.T) {
return nil
})
svc, _ := core.ServiceFor[*Service](core, "process")
svc, _ := framework.ServiceFor[*Service](c, "process")
proc, err := svc.Start(context.Background(), "echo", "test")
require.NoError(t, err)