test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
package core_test
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"embed"
|
|
|
|
|
"io"
|
|
|
|
|
"testing"
|
|
|
|
|
|
2026-03-20 21:00:48 +00:00
|
|
|
. "dappco.re/go/core"
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
//go:embed testdata
|
|
|
|
|
var testFS embed.FS
|
|
|
|
|
|
|
|
|
|
// --- Data (Embedded Content Mounts) ---
|
|
|
|
|
|
2026-03-24 20:28:52 +00:00
|
|
|
func mountTestData(t *testing.T, c *Core, name string) {
|
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
|
|
r := c.Data().New(NewOptions(
|
|
|
|
|
Option{Key: "name", Value: name},
|
|
|
|
|
Option{Key: "source", Value: testFS},
|
|
|
|
|
Option{Key: "path", Value: "testdata"},
|
|
|
|
|
))
|
|
|
|
|
assert.True(t, r.OK)
|
|
|
|
|
}
|
|
|
|
|
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
func TestData_New_Good(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
feat: WithService with v0.3.3 name discovery + IPC handler auto-registration
- WithService now calls factory, discovers service name from package path via
reflect/runtime (last path segment, _test suffix stripped, lowercased), and
calls RegisterService — which handles Startable/Stoppable/HandleIPCEvents
- If factory returns nil Value (self-registered), WithService returns OK without
a second registration
- Add contract_test.go with _Good/_Bad tests covering all three code paths
- Fix core.go Cli() accessor: use ServiceFor[*Cli](c, "cli") (was cli.New())
- Fix pre-existing })) → }}) syntax errors in command_test, service_test, lock_test
- Fix pre-existing Options{...} → NewOptions(...) in core_test, data_test,
drive_test, i18n_test (Options is a struct, not a slice)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-24 20:02:53 +00:00
|
|
|
r := c.Data().New(NewOptions(
|
|
|
|
|
Option{Key: "name", Value: "test"},
|
|
|
|
|
Option{Key: "source", Value: testFS},
|
2026-03-24 20:28:52 +00:00
|
|
|
Option{Key: "path", Value: "testdata"},
|
feat: WithService with v0.3.3 name discovery + IPC handler auto-registration
- WithService now calls factory, discovers service name from package path via
reflect/runtime (last path segment, _test suffix stripped, lowercased), and
calls RegisterService — which handles Startable/Stoppable/HandleIPCEvents
- If factory returns nil Value (self-registered), WithService returns OK without
a second registration
- Add contract_test.go with _Good/_Bad tests covering all three code paths
- Fix core.go Cli() accessor: use ServiceFor[*Cli](c, "cli") (was cli.New())
- Fix pre-existing })) → }}) syntax errors in command_test, service_test, lock_test
- Fix pre-existing Options{...} → NewOptions(...) in core_test, data_test,
drive_test, i18n_test (Options is a struct, not a slice)
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-24 20:02:53 +00:00
|
|
|
))
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
assert.True(t, r.OK)
|
|
|
|
|
assert.NotNil(t, r.Value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_New_Bad(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
|
2026-03-24 19:17:12 +00:00
|
|
|
r := c.Data().New(NewOptions(Option{Key: "source", Value: testFS}))
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
assert.False(t, r.OK)
|
|
|
|
|
|
2026-03-24 19:17:12 +00:00
|
|
|
r = c.Data().New(NewOptions(Option{Key: "name", Value: "test"}))
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
assert.False(t, r.OK)
|
|
|
|
|
|
2026-03-24 19:17:12 +00:00
|
|
|
r = c.Data().New(NewOptions(Option{Key: "name", Value: "test"}, Option{Key: "source", Value: "not-an-fs"}))
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
assert.False(t, r.OK)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_ReadString_Good(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
2026-03-24 20:28:52 +00:00
|
|
|
mountTestData(t, c, "app")
|
|
|
|
|
r := c.Data().ReadString("app/test.txt")
|
feat: embed.go and data.go return Result throughout
Mount, MountEmbed, Open, ReadFile, ReadString, Sub, GetAsset,
GetAssetBytes, ScanAssets, GeneratePack, Extract → all return Result.
Data.ReadFile, ReadString, List, ListNames, Extract → Result.
Data.New uses Mount's Result internally.
Internal helpers (WalkDir callback, copyFile) stay error — they're
not public API.
231 tests, 77.4% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 14:13:47 +00:00
|
|
|
assert.True(t, r.OK)
|
|
|
|
|
assert.Equal(t, "hello from testdata\n", r.Value.(string))
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_ReadString_Bad(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
feat: embed.go and data.go return Result throughout
Mount, MountEmbed, Open, ReadFile, ReadString, Sub, GetAsset,
GetAssetBytes, ScanAssets, GeneratePack, Extract → all return Result.
Data.ReadFile, ReadString, List, ListNames, Extract → Result.
Data.New uses Mount's Result internally.
Internal helpers (WalkDir callback, copyFile) stay error — they're
not public API.
231 tests, 77.4% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 14:13:47 +00:00
|
|
|
r := c.Data().ReadString("nonexistent/file.txt")
|
|
|
|
|
assert.False(t, r.OK)
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_ReadFile_Good(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
2026-03-24 20:28:52 +00:00
|
|
|
mountTestData(t, c, "app")
|
feat: embed.go and data.go return Result throughout
Mount, MountEmbed, Open, ReadFile, ReadString, Sub, GetAsset,
GetAssetBytes, ScanAssets, GeneratePack, Extract → all return Result.
Data.ReadFile, ReadString, List, ListNames, Extract → Result.
Data.New uses Mount's Result internally.
Internal helpers (WalkDir callback, copyFile) stay error — they're
not public API.
231 tests, 77.4% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 14:13:47 +00:00
|
|
|
r := c.Data().ReadFile("app/test.txt")
|
|
|
|
|
assert.True(t, r.OK)
|
|
|
|
|
assert.Equal(t, "hello from testdata\n", string(r.Value.([]byte)))
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_Get_Good(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
2026-03-24 20:28:52 +00:00
|
|
|
mountTestData(t, c, "brain")
|
2026-03-20 16:46:39 +00:00
|
|
|
gr := c.Data().Get("brain")
|
|
|
|
|
assert.True(t, gr.OK)
|
|
|
|
|
emb := gr.Value.(*Embed)
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
|
feat: embed.go and data.go return Result throughout
Mount, MountEmbed, Open, ReadFile, ReadString, Sub, GetAsset,
GetAssetBytes, ScanAssets, GeneratePack, Extract → all return Result.
Data.ReadFile, ReadString, List, ListNames, Extract → Result.
Data.New uses Mount's Result internally.
Internal helpers (WalkDir callback, copyFile) stay error — they're
not public API.
231 tests, 77.4% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 14:13:47 +00:00
|
|
|
r := emb.Open("test.txt")
|
|
|
|
|
assert.True(t, r.OK)
|
|
|
|
|
file := r.Value.(io.ReadCloser)
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
defer file.Close()
|
|
|
|
|
content, _ := io.ReadAll(file)
|
|
|
|
|
assert.Equal(t, "hello from testdata\n", string(content))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_Get_Bad(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
2026-03-20 16:46:39 +00:00
|
|
|
r := c.Data().Get("nonexistent")
|
|
|
|
|
assert.False(t, r.OK)
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_Mounts_Good(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
2026-03-24 20:28:52 +00:00
|
|
|
mountTestData(t, c, "a")
|
|
|
|
|
mountTestData(t, c, "b")
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
mounts := c.Data().Mounts()
|
|
|
|
|
assert.Len(t, mounts, 2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestEmbed_Legacy_Good(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
2026-03-24 20:28:52 +00:00
|
|
|
mountTestData(t, c, "app")
|
feat: embed.go and data.go return Result throughout
Mount, MountEmbed, Open, ReadFile, ReadString, Sub, GetAsset,
GetAssetBytes, ScanAssets, GeneratePack, Extract → all return Result.
Data.ReadFile, ReadString, List, ListNames, Extract → Result.
Data.New uses Mount's Result internally.
Internal helpers (WalkDir callback, copyFile) stay error — they're
not public API.
231 tests, 77.4% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 14:13:47 +00:00
|
|
|
assert.NotNil(t, c.Embed())
|
test: rewrite test suite for AX primitives API
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>
2026-03-20 08:42:38 +00:00
|
|
|
}
|
test: 200 tests, 50.2% coverage — Data, I18n, Fs, Log, Embed, Runtime
New tests: Data List/ListNames/Extract, I18n with mock Translator,
Fs full surface (EnsureDir, IsDir, IsFile, Exists, List, Stat, Open,
Create, Append, ReadStream, WriteStream, Delete, DeleteAll, Rename),
Log all levels + Security + Username + Default + LogErr + LogPan,
Embed ScanAssets + GeneratePack + MountEmbed, Runtime ServiceName,
Core LogError/LogWarn/Must helpers.
Fixes: NewCommand inits flagset, New() wires Cli root command + app.
Remaining 0% (excluding CLI/App): compress, getAllFiles (internal),
Reports/appendReport (needs ErrorPanic filePath), SetOutput (trivial).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 10:49:33 +00:00
|
|
|
|
|
|
|
|
func TestData_List_Good(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
2026-03-24 20:28:52 +00:00
|
|
|
mountTestData(t, c, "app")
|
|
|
|
|
r := c.Data().List("app/.")
|
feat: embed.go and data.go return Result throughout
Mount, MountEmbed, Open, ReadFile, ReadString, Sub, GetAsset,
GetAssetBytes, ScanAssets, GeneratePack, Extract → all return Result.
Data.ReadFile, ReadString, List, ListNames, Extract → Result.
Data.New uses Mount's Result internally.
Internal helpers (WalkDir callback, copyFile) stay error — they're
not public API.
231 tests, 77.4% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 14:13:47 +00:00
|
|
|
assert.True(t, r.OK)
|
test: 200 tests, 50.2% coverage — Data, I18n, Fs, Log, Embed, Runtime
New tests: Data List/ListNames/Extract, I18n with mock Translator,
Fs full surface (EnsureDir, IsDir, IsFile, Exists, List, Stat, Open,
Create, Append, ReadStream, WriteStream, Delete, DeleteAll, Rename),
Log all levels + Security + Username + Default + LogErr + LogPan,
Embed ScanAssets + GeneratePack + MountEmbed, Runtime ServiceName,
Core LogError/LogWarn/Must helpers.
Fixes: NewCommand inits flagset, New() wires Cli root command + app.
Remaining 0% (excluding CLI/App): compress, getAllFiles (internal),
Reports/appendReport (needs ErrorPanic filePath), SetOutput (trivial).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 10:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_List_Bad(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
feat: embed.go and data.go return Result throughout
Mount, MountEmbed, Open, ReadFile, ReadString, Sub, GetAsset,
GetAssetBytes, ScanAssets, GeneratePack, Extract → all return Result.
Data.ReadFile, ReadString, List, ListNames, Extract → Result.
Data.New uses Mount's Result internally.
Internal helpers (WalkDir callback, copyFile) stay error — they're
not public API.
231 tests, 77.4% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 14:13:47 +00:00
|
|
|
r := c.Data().List("nonexistent/path")
|
|
|
|
|
assert.False(t, r.OK)
|
test: 200 tests, 50.2% coverage — Data, I18n, Fs, Log, Embed, Runtime
New tests: Data List/ListNames/Extract, I18n with mock Translator,
Fs full surface (EnsureDir, IsDir, IsFile, Exists, List, Stat, Open,
Create, Append, ReadStream, WriteStream, Delete, DeleteAll, Rename),
Log all levels + Security + Username + Default + LogErr + LogPan,
Embed ScanAssets + GeneratePack + MountEmbed, Runtime ServiceName,
Core LogError/LogWarn/Must helpers.
Fixes: NewCommand inits flagset, New() wires Cli root command + app.
Remaining 0% (excluding CLI/App): compress, getAllFiles (internal),
Reports/appendReport (needs ErrorPanic filePath), SetOutput (trivial).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 10:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_ListNames_Good(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
2026-03-24 20:28:52 +00:00
|
|
|
mountTestData(t, c, "app")
|
|
|
|
|
r := c.Data().ListNames("app/.")
|
feat: embed.go and data.go return Result throughout
Mount, MountEmbed, Open, ReadFile, ReadString, Sub, GetAsset,
GetAssetBytes, ScanAssets, GeneratePack, Extract → all return Result.
Data.ReadFile, ReadString, List, ListNames, Extract → Result.
Data.New uses Mount's Result internally.
Internal helpers (WalkDir callback, copyFile) stay error — they're
not public API.
231 tests, 77.4% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 14:13:47 +00:00
|
|
|
assert.True(t, r.OK)
|
|
|
|
|
assert.Contains(t, r.Value.([]string), "test")
|
test: 200 tests, 50.2% coverage — Data, I18n, Fs, Log, Embed, Runtime
New tests: Data List/ListNames/Extract, I18n with mock Translator,
Fs full surface (EnsureDir, IsDir, IsFile, Exists, List, Stat, Open,
Create, Append, ReadStream, WriteStream, Delete, DeleteAll, Rename),
Log all levels + Security + Username + Default + LogErr + LogPan,
Embed ScanAssets + GeneratePack + MountEmbed, Runtime ServiceName,
Core LogError/LogWarn/Must helpers.
Fixes: NewCommand inits flagset, New() wires Cli root command + app.
Remaining 0% (excluding CLI/App): compress, getAllFiles (internal),
Reports/appendReport (needs ErrorPanic filePath), SetOutput (trivial).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 10:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_Extract_Good(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
2026-03-24 20:28:52 +00:00
|
|
|
mountTestData(t, c, "app")
|
|
|
|
|
r := c.Data().Extract("app/.", t.TempDir(), nil)
|
feat: embed.go and data.go return Result throughout
Mount, MountEmbed, Open, ReadFile, ReadString, Sub, GetAsset,
GetAssetBytes, ScanAssets, GeneratePack, Extract → all return Result.
Data.ReadFile, ReadString, List, ListNames, Extract → Result.
Data.New uses Mount's Result internally.
Internal helpers (WalkDir callback, copyFile) stay error — they're
not public API.
231 tests, 77.4% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 14:13:47 +00:00
|
|
|
assert.True(t, r.OK)
|
test: 200 tests, 50.2% coverage — Data, I18n, Fs, Log, Embed, Runtime
New tests: Data List/ListNames/Extract, I18n with mock Translator,
Fs full surface (EnsureDir, IsDir, IsFile, Exists, List, Stat, Open,
Create, Append, ReadStream, WriteStream, Delete, DeleteAll, Rename),
Log all levels + Security + Username + Default + LogErr + LogPan,
Embed ScanAssets + GeneratePack + MountEmbed, Runtime ServiceName,
Core LogError/LogWarn/Must helpers.
Fixes: NewCommand inits flagset, New() wires Cli root command + app.
Remaining 0% (excluding CLI/App): compress, getAllFiles (internal),
Reports/appendReport (needs ErrorPanic filePath), SetOutput (trivial).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 10:49:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestData_Extract_Bad(t *testing.T) {
|
2026-03-24 16:23:33 +00:00
|
|
|
c := New().Value.(*Core)
|
feat: embed.go and data.go return Result throughout
Mount, MountEmbed, Open, ReadFile, ReadString, Sub, GetAsset,
GetAssetBytes, ScanAssets, GeneratePack, Extract → all return Result.
Data.ReadFile, ReadString, List, ListNames, Extract → Result.
Data.New uses Mount's Result internally.
Internal helpers (WalkDir callback, copyFile) stay error — they're
not public API.
231 tests, 77.4% coverage.
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 14:13:47 +00:00
|
|
|
r := c.Data().Extract("nonexistent/path", t.TempDir(), nil)
|
|
|
|
|
assert.False(t, r.OK)
|
test: 200 tests, 50.2% coverage — Data, I18n, Fs, Log, Embed, Runtime
New tests: Data List/ListNames/Extract, I18n with mock Translator,
Fs full surface (EnsureDir, IsDir, IsFile, Exists, List, Stat, Open,
Create, Append, ReadStream, WriteStream, Delete, DeleteAll, Rename),
Log all levels + Security + Username + Default + LogErr + LogPan,
Embed ScanAssets + GeneratePack + MountEmbed, Runtime ServiceName,
Core LogError/LogWarn/Must helpers.
Fixes: NewCommand inits flagset, New() wires Cli root command + app.
Remaining 0% (excluding CLI/App): compress, getAllFiles (internal),
Reports/appendReport (needs ErrorPanic filePath), SetOutput (trivial).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-20 10:49:33 +00:00
|
|
|
}
|