diff options
| author | James O'Doherty <james@theodohertyfamily.com> | 2026-05-22 09:18:55 -0400 |
|---|---|---|
| committer | James O'Doherty <james@theodohertyfamily.com> | 2026-05-22 09:18:55 -0400 |
| commit | 96d75d9f1fab87365d7e6b5070eed3a5757c3484 (patch) | |
| tree | e01144dbb5338826d36f1b07444ebd78407c3bf4 /internal/cli/cli_test.go | |
| parent | 756ba94292b408cc4f23d137b2c4c52009b2b38d (diff) | |
Refactor CLI for testability and implement hermetic config path injection
Diffstat (limited to 'internal/cli/cli_test.go')
| -rw-r--r-- | internal/cli/cli_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go new file mode 100644 index 0000000..71ff6cb --- /dev/null +++ b/internal/cli/cli_test.go @@ -0,0 +1,34 @@ +package cli + +import ( + "testing" +) + +func TestAppRun_ProfileDirInjection(t *testing.T) { + // 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 + + err := app.Run() + if (err != nil) != tt.wantErr { + t.Errorf("App.Run() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} |
