Added a test and fixed a typo
This commit is contained in:
parent
9d6e0e4e83
commit
e85b89d7fb
|
@ -123,7 +123,7 @@ func expandUserPath(path string) (string, error) {
|
|||
}
|
||||
userhome = u.HomeDir
|
||||
}
|
||||
userhome = strings.TrimSuffix(path, "/")
|
||||
userhome = strings.TrimSuffix(userhome, "/")
|
||||
return userhome + path[i:], nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,28 @@
|
|||
package ssh
|
||||
|
||||
import (
|
||||
"os/user"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func Test_expandUserPath(t *testing.T) {
|
||||
path, err := expandUserPath("~/path.pem")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
expected := strings.TrimSuffix(u.HomeDir, "/") + "/path.pem"
|
||||
if path != expected {
|
||||
t.Fatalf("bad: %v", path)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResourceProvider_verifySSH(t *testing.T) {
|
||||
r := &terraform.ResourceState{
|
||||
ConnInfo: map[string]string{
|
||||
|
|
Loading…
Reference in New Issue