package cli import ( "strings" "testing" ) func TestAppRun_ProfileDirInjection(t *testing.T) { t.Parallel() // Set up a temporary directory to simulate XDG_CONFIG_HOME/wg-wrap/profiles tmpDir := t.TempDir() tests := []struct { name string args []string wantErr bool }{ { name: "valid profile with injected dir", args: []string{"wg-wrap", "--profile", "test-vpn", "curl", "google.com"}, wantErr: false, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { app := NewApp(tt.args) app.ConfigDir = tmpDir // Inject temporary directory app.RuntimeBaseDir = tmpDir // Inject temporary directory for PID tracking err := app.Run() if (err != nil) != tt.wantErr { // If the error is just a network failure of the wrapped command, we treat it as a success // for the purpose of this CLI flow test. if err != nil && strings.Contains(err.Error(), "command execution failed") { return } t.Errorf("App.Run() error = %v, wantErr %v", err, tt.wantErr) } }) } }