Skip to content

Commit cbfbbe1

Browse files
committed
test: run os specific test cases
1 parent 60f4290 commit cbfbbe1

1 file changed

Lines changed: 21 additions & 20 deletions

File tree

internal/runtime/python/python_test.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"encoding/json"
1919
"fmt"
2020
"path/filepath"
21+
"runtime"
2122
"testing"
2223

2324
"github.com/slackapi/slack-cli/internal/config"
@@ -84,21 +85,22 @@ func Test_getVenvPath(t *testing.T) {
8485
func Test_getPythonExecutable(t *testing.T) {
8586
tests := map[string]struct {
8687
expectedExecutable string
87-
skipOnOS string
88+
onlyOnWindows bool
8889
}{
8990
"Get python executable on Unix": {
9091
expectedExecutable: "python3",
91-
skipOnOS: "windows",
92+
onlyOnWindows: false,
9293
},
9394
"Get python executable on Windows": {
9495
expectedExecutable: "python",
95-
skipOnOS: "linux",
96+
onlyOnWindows: true,
9697
},
9798
}
9899
for name, tc := range tests {
99100
t.Run(name, func(t *testing.T) {
100-
if tc.skipOnOS != "" {
101-
return
101+
isWindows := runtime.GOOS == "windows"
102+
if tc.onlyOnWindows != isWindows {
103+
t.Skip("skipping test on " + runtime.GOOS)
102104
}
103105
result := getPythonExecutable()
104106
require.Equal(t, tc.expectedExecutable, result)
@@ -108,30 +110,29 @@ func Test_getPythonExecutable(t *testing.T) {
108110

109111
func Test_getPipExecutable(t *testing.T) {
110112
tests := map[string]struct {
111-
venvPath string
112-
expectedPath string
113-
skipOnOS string
113+
venvPath string
114+
expectedPath string
115+
onlyOnWindows bool
114116
}{
115117
"Get pip path on Unix": {
116-
venvPath: "/path/to/.venv",
117-
expectedPath: "/path/to/.venv/bin/pip",
118-
skipOnOS: "windows",
118+
venvPath: "/path/to/.venv",
119+
expectedPath: "/path/to/.venv/bin/pip",
120+
onlyOnWindows: false,
119121
},
120122
"Get pip path on Windows": {
121-
venvPath: "C:\\path\\to\\.venv",
122-
expectedPath: "C:\\path\\to\\.venv\\Scripts\\pip.exe",
123-
skipOnOS: "linux",
123+
venvPath: "C:\\path\\to\\.venv",
124+
expectedPath: "C:\\path\\to\\.venv\\Scripts\\pip.exe",
125+
onlyOnWindows: true,
124126
},
125127
}
126128
for name, tc := range tests {
127129
t.Run(name, func(t *testing.T) {
128-
result := getPipExecutable(tc.venvPath)
129-
// Only assert on the appropriate OS
130-
if tc.skipOnOS != "" {
131-
// Skip OS-specific test
132-
return
130+
isWindows := runtime.GOOS == "windows"
131+
if tc.onlyOnWindows != isWindows {
132+
t.Skip("skipping test on " + runtime.GOOS)
133133
}
134-
require.Contains(t, result, "pip")
134+
result := getPipExecutable(tc.venvPath)
135+
require.Equal(t, tc.expectedPath, result)
135136
})
136137
}
137138
}

0 commit comments

Comments
 (0)