@@ -3,17 +3,30 @@ package tests
33import (
44 "encoding/json"
55 "fmt"
6- pythondeployer "go.flow.arcalot.io/pythondeployer"
7- wrapper "go.flow.arcalot.io/pythondeployer/internal/cliwrapper"
8- "go.flow.arcalot.io/pythondeployer/internal/config"
96 "go.arcalot.io/assert"
107 "go.arcalot.io/log/v2"
118 "go.flow.arcalot.io/deployer"
9+ pythondeployer "go.flow.arcalot.io/pythondeployer"
10+ wrapper "go.flow.arcalot.io/pythondeployer/internal/cliwrapper"
11+ "go.flow.arcalot.io/pythondeployer/internal/config"
1212 "math/rand"
1313 "os"
14+ "os/exec"
1415 "testing"
1516)
1617
18+ func getPythonPath () (string , error ) {
19+ python3Path , errPython3 := exec .LookPath ("python3" )
20+ if errPython3 != nil {
21+ pythonPath , errPython := exec .LookPath ("python" )
22+ if errPython != nil {
23+ return "" , fmt .Errorf ("error getting Python3 (%s) and python (%s)" , errPython3 , errPython )
24+ }
25+ return pythonPath , nil
26+ }
27+ return python3Path , nil
28+ }
29+
1730func createWorkdir (t * testing.T ) string {
1831 workdir := fmt .Sprintf ("/tmp/%s" , randString (10 ))
1932 if _ , err := os .Stat (workdir ); ! os .IsNotExist (err ) {
@@ -52,7 +65,7 @@ func pullModule(python wrapper.CliWrapper, module string, workDir string, t *tes
5265}
5366
5467func getCliWrapper (t * testing.T , workdir string ) wrapper.CliWrapper {
55- workDir := workdir
68+ workDir := workdir
5669 pythonPath := "/usr/bin/python3.9"
5770 logger := log .NewTestLogger (t )
5871 return wrapper .NewCliWrapper (pythonPath , workDir , logger )
@@ -67,6 +80,9 @@ func getConnector(t *testing.T, configJSON string, workdir *string) (deployer.Co
6780 schema := factory .ConfigurationSchema ()
6881 unserializedConfig , err := schema .UnserializeType (serializedConfig )
6982 assert .NoError (t , err )
83+ pythonPath , err := getPythonPath ()
84+ assert .NoError (t , err )
85+ unserializedConfig .PythonPath = pythonPath
7086 // NOTE: randomizing Workdir to avoid parallel tests to
7187 // remove python folders while other tests are running
7288 // causing the test to fail
0 commit comments