Fixes debug info test for windows
@@ -2,6 +2,7 @@ package debug
import (
"encoding/json"
+ "github.com/openshift/odo/pkg/util"
"os"
"reflect"
"testing"
@@ -177,7 +178,6 @@ func Test_getDebugInfo(t *testing.T) {
AppName: "app",
ComponentName: "nodejs-ex",
RemotePort: 5858,
- LocalPort: 9001,
},
readDebugFile: OdoDebugFile{
TypeMeta: v1.TypeMeta{
@@ -189,7 +189,6 @@ func Test_getDebugInfo(t *testing.T) {
AppName: "app",
ComponentName: "nodejs-ex",
RemotePort: 5858,
- LocalPort: 9001,
},
debugPortListening: true,
fileExists: true,
@@ -231,7 +230,6 @@ func Test_getDebugInfo(t *testing.T) {
AppName: "app",
ComponentName: "nodejs-ex",
RemotePort: 5858,
- LocalPort: 9001,
},
fileExists: true,
debugRunning: false,
@@ -257,7 +255,6 @@ func Test_getDebugInfo(t *testing.T) {
AppName: "app",
ComponentName: "nodejs-ex",
RemotePort: 5858,
- LocalPort: 9001,
},
fileExists: true,
debugRunning: false,
@@ -271,6 +268,19 @@ func Test_getDebugInfo(t *testing.T) {
client.Namespace = "testing-1"
tt.args.defaultPortForwarder.client = client
+ freePort, err := util.HttpGetFreePort()
+ if err != nil {
+ t.Errorf("error occured while getting a free port, cause: %v", err)
+ }
+
+ if (OdoDebugFile{}) != tt.readDebugFile {
+ tt.readDebugFile.LocalPort = freePort
+ }
+
+ if (OdoDebugFile{}) != tt.wantDebugFile {
+ tt.wantDebugFile.LocalPort = freePort
+ }
+
odoDebugFilePath := GetDebugInfoFilePath(tt.args.defaultPortForwarder.client, tt.args.defaultPortForwarder.componentName, tt.args.defaultPortForwarder.appName)
if tt.fileExists {
fakeString, err := fakeOdoDebugFileString(tt.readDebugFile.TypeMeta,
