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>
37 lines
772 B
Go
37 lines
772 B
Go
package core_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "forge.lthn.ai/core/go/pkg/core"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// --- Log (Structured Logger) ---
|
|
|
|
func TestLog_New_Good(t *testing.T) {
|
|
l := NewLog(LogOpts{Level: LevelInfo})
|
|
assert.NotNil(t, l)
|
|
}
|
|
|
|
func TestLog_Levels_Good(t *testing.T) {
|
|
for _, level := range []Level{LevelDebug, LevelInfo, LevelWarn, LevelError} {
|
|
l := NewLog(LogOpts{Level: level})
|
|
l.Debug("debug msg")
|
|
l.Info("info msg")
|
|
l.Warn("warn msg")
|
|
l.Error("error msg")
|
|
}
|
|
}
|
|
|
|
func TestLog_CoreLog_Good(t *testing.T) {
|
|
c := New()
|
|
assert.NotNil(t, c.Log())
|
|
}
|
|
|
|
func TestLog_ErrorSink_Interface(t *testing.T) {
|
|
l := NewLog(LogOpts{Level: LevelInfo})
|
|
var sink ErrorSink = l
|
|
sink.Error("test", "key", "val")
|
|
sink.Warn("test", "key", "val")
|
|
}
|