Skip to content

Commit

Permalink
[fix] fixed failing ssh tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deven96 committed Mar 21, 2022
1 parent 76aed4a commit 36a4917
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
10 changes: 5 additions & 5 deletions driver/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ func (d *SSH) GetDetails() SystemDetails {
windowsName, err := d.RunCommand(`systeminfo | findstr /R /C:Windows`)
if err == nil {
if strings.Contains(strings.ToLower(windowsName), "windows") {
uname = "windows"
uname = "Windows"
}
}
}
details := &SystemDetails{}
details.Name = uname
details.Name = strings.TrimSpace(strings.Trim(uname, "\n"))
switch details.Name {
case "windows":
case "Windows":
details.IsWindows = true
case "linux":
case "Linux":
details.IsLinux = true
case "darwin":
case "Darwin":
details.IsDarwin = true
}
d.Info = details
Expand Down
2 changes: 1 addition & 1 deletion driver/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ func TestSSHSystemDetails(t *testing.T) {
d := NewSSHForTest()
details := d.GetDetails()
if !details.IsLinux {
t.Errorf("Expected linux server for ssh test got %s", details.Name)
t.Errorf("Expected linux server for ssh test got %#v", details)
}
}
16 changes: 11 additions & 5 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package integration

import (
"fmt"
"os"
"path/filepath"
"strings"
"testing"

Expand All @@ -18,12 +20,16 @@ func NewWebForTest() driver.Driver {
}

func NewSSHForTest() driver.Driver {
_ = config.GetConfig()
workingDir, _ := os.Getwd()
workingDir = filepath.Dir(workingDir)
yamlPath := fmt.Sprintf("%s/%s", workingDir, "config-test.yaml")
conf := config.LoadConfig(yamlPath)
dashboardInfo := config.GetDashboardInfoConfig(conf)
return &driver.SSH{
User: "dev",
Host: "127.0.0.1",
Port: 2222,
KeyFile: "/home/diretnan/.ssh/id_rsa",
User: dashboardInfo.Hosts[0].Connection.Username,
Host: dashboardInfo.Hosts[0].Address,
Port: int(dashboardInfo.Hosts[0].Connection.Port),
KeyFile: dashboardInfo.Hosts[0].Connection.PrivateKeyPath,
KeyPass: "",
CheckKnownHosts: false,
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/prep-test-ssh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SSH_HOST="$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" saido-linux-ssh
cat <<EOF > config-test.yaml
hosts:
children:
"${SSH_HOST}":
"0.0.0.0":
connection:
type: ssh
username: ${SSH_USER}
Expand Down

0 comments on commit 36a4917

Please sign in to comment.