summaryrefslogtreecommitdiff
path: root/internal/cli/cli_test.go
blob: 71ff6cb6f5553f66aaa2d215e1aa77b3e8e708b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)
			}
		})
	}
}