164 tests, 41.3% coverage. Tests written against the public API only (external test package, no _test.go in pkg/core/). Covers: New(Options), Data, Drive, Config, Service, Error, IPC, Fs, Cli, Lock, Array, Log, App, Runtime, Task. Fixes: NewCommand now inits flagset, New() wires Cli root command. Old tests removed — they referenced With*, RegisterService, and other patterns that no longer exist. Co-Authored-By: Virgil <virgil@lethean.io>
40 lines
798 B
Go
40 lines
798 B
Go
package core_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "forge.lthn.ai/core/go/pkg/core"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// --- App ---
|
|
|
|
func TestApp_Good(t *testing.T) {
|
|
c := New(Options{{K: "name", V: "myapp"}})
|
|
assert.Equal(t, "myapp", c.App().Name)
|
|
}
|
|
|
|
func TestApp_Empty_Good(t *testing.T) {
|
|
c := New()
|
|
assert.NotNil(t, c.App())
|
|
assert.Equal(t, "", c.App().Name)
|
|
}
|
|
|
|
func TestApp_Runtime_Good(t *testing.T) {
|
|
c := New()
|
|
c.App().Runtime = &struct{ Name string }{Name: "wails"}
|
|
assert.NotNil(t, c.App().Runtime)
|
|
}
|
|
|
|
func TestApp_Find_Good(t *testing.T) {
|
|
app := Find("go", "go")
|
|
// Find looks for a binary — go should be in PATH
|
|
if app != nil {
|
|
assert.NotEmpty(t, app.Path)
|
|
}
|
|
}
|
|
|
|
func TestApp_Find_Bad(t *testing.T) {
|
|
app := Find("nonexistent-binary-xyz", "test")
|
|
assert.Nil(t, app)
|
|
}
|