feat(cli): add apply subcommand

This commit is contained in:
2026-05-23 03:32:21 +01:00
parent 85fbbafb71
commit 68035b378c
15 changed files with 889 additions and 1 deletions
+31
View File
@@ -0,0 +1,31 @@
package cli
import (
"bytes"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/lukaszraczylo/harness-sync/internal/adapter"
)
func TestDiffInvokesDryRun(t *testing.T) {
root := t.TempDir()
require.NoError(t, os.WriteFile(filepath.Join(root, "config.yaml"), []byte("active_profile: home\n"), 0o600))
require.NoError(t, os.MkdirAll(filepath.Join(root, "profiles"), 0o750))
require.NoError(t, os.WriteFile(filepath.Join(root, "profiles", "home.yaml"),
[]byte("name: home\ngateway:\n url: u\n token: t\n default_model: m\nmodels:\n - {id: m}\n"), 0o600))
reg := adapter.NewRegistry()
reg.Register(&detectableAdapter{name: "stub", detect: true})
var buf bytes.Buffer
cmd := NewDiff(reg)
cmd.SetOut(&buf)
cmd.SetArgs([]string{"--root", root})
require.NoError(t, cmd.Execute())
assert.Contains(t, buf.String(), "dry-run")
}