feat: toml config support (#9)

## What's new
- TOML config support 
- add config init command to justfile
https://github.com/versenilvis/IRIS/pull/9/commits/a5bb6c23d74ca73385b3590d2eb275ce6429906b
- add copy binary file to local bin on reload
https://github.com/versenilvis/IRIS/pull/9/commits/4da3acdbc58c28f20fa0021d15fec82823ba392b
- init config on setup
https://github.com/versenilvis/IRIS/pull/9/commits/fb48b6bb832f38e24fab9211d92858bab9a58a07

## Fix
- add lsof to support macos because /proc filesystem is Linux-specific
and does not exist on macOS 0439d829573864fcf902fc4127f7d45384bfab01
- git push doesnt suggest current branch, fix
https://github.com/versenilvis/IRIS/pull/9/commits/b498532b401b764a4a1a2c70b3cb44b7caf72320
- use timeout context for lsof command in reload handler
https://github.com/versenilvis/IRIS/pull/9/commits/1a2baee951e6538a729da12aedfe53960e51102d
This commit is contained in:
VERSE
2026-05-30 22:05:06 +07:00
committed by GitHub
parent 8556fa626a
commit 3d76a3ee88
21 changed files with 1064 additions and 160 deletions
+25 -15
View File
@@ -4,7 +4,9 @@ import (
"os"
"path/filepath"
"testing"
"time"
"github.com/versenilvis/iris/config"
"github.com/versenilvis/iris/root"
)
@@ -43,25 +45,33 @@ func TestUpdateState(t *testing.T) {
// Override home dir for testing
homeBackup := os.Getenv("HOME")
if err := os.Setenv("HOME", tmpDir); err != nil {
err = os.Setenv("HOME", tmpDir)
if err != nil {
t.Fatal(err)
}
defer func() { _ = os.Setenv("HOME", homeBackup) }()
// Ensure .iris directory exists
_ = os.MkdirAll(filepath.Join(tmpDir, ".iris"), 0755)
state := root.LoadUpdateState()
state.SeenVersion = "v1.0.0"
state.LastCheck = 123456789
root.SaveUpdateState(state)
loaded := root.LoadUpdateState()
if loaded.SeenVersion != state.SeenVersion {
t.Errorf("Expected SeenVersion %q, got %q", state.SeenVersion, loaded.SeenVersion)
xdgBackup := os.Getenv("XDG_DATA_HOME")
err = os.Setenv("XDG_DATA_HOME", filepath.Join(tmpDir, ".local", "share"))
if err != nil {
t.Fatal(err)
}
if loaded.LastCheck != state.LastCheck {
t.Errorf("Expected LastCheck %d, got %d", state.LastCheck, loaded.LastCheck)
defer func() { _ = os.Setenv("XDG_DATA_HOME", xdgBackup) }()
state := config.LoadState()
state.Updater.SeenVersion = "v1.0.0"
state.Updater.LastCheckTime = time.Unix(123456789, 0)
err = config.SaveState(state)
if err != nil {
t.Fatalf("failed to save state: %v", err)
}
loaded := config.LoadState()
if loaded.Updater.SeenVersion != state.Updater.SeenVersion {
t.Errorf("Expected SeenVersion %q, got %q", state.Updater.SeenVersion, loaded.Updater.SeenVersion)
}
if loaded.Updater.LastCheckTime.Unix() != state.Updater.LastCheckTime.Unix() {
t.Errorf("Expected LastCheck %v, got %v", state.Updater.LastCheckTime, loaded.Updater.LastCheckTime)
}
}