Skip to content

Commit 83fe0ff

Browse files
committed
Testing GeneratingAnSSHKey
1 parent 9aeaaec commit 83fe0ff

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

pkg/utils/utils_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package utils
22

33
import (
4+
"io/ioutil"
5+
"os"
6+
"path/filepath"
47
"sort"
58
"strings"
69
"testing"
@@ -84,3 +87,28 @@ func TestGetConfigFilePath(t *testing.T) {
8487
So(strings.Contains(configPath, homedir), ShouldBeTrue)
8588
})
8689
}
90+
91+
func TestGeneratingAnSSHKey(t *testing.T) {
92+
Convey("Testing GeneratingAnSSHKey()", t, func() {
93+
streams := SpawnRedirection{
94+
Stdout: os.Stdout,
95+
Stderr: os.Stderr,
96+
Stdin: os.Stdin,
97+
}
98+
99+
tmpDir, err := ioutil.TempDir("/tmp", "scaleway-test")
100+
So(err, ShouldBeNil)
101+
102+
tmpFile, err := ioutil.TempFile(tmpDir, "ssh-key")
103+
So(err, ShouldBeNil)
104+
105+
err = os.Remove(tmpFile.Name())
106+
So(err, ShouldBeNil)
107+
108+
filePath, err := GeneratingAnSSHKey(streams, tmpDir, filepath.Base(tmpFile.Name()))
109+
So(err, ShouldBeNil)
110+
So(filePath, ShouldEqual, tmpFile.Name())
111+
112+
os.Remove(tmpFile.Name())
113+
})
114+
}

0 commit comments

Comments
 (0)