-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9232521
commit 7a31d32
Showing
12 changed files
with
201 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cmd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/atotto/clipboard" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestExecuteClienAddCmd(t *testing.T) { | ||
//runAddCmd() | ||
assert.Nil(t, nil) | ||
} | ||
|
||
func TestCopyToClipboard(t *testing.T) { | ||
myString := "My String" | ||
err := copyClipboard(myString) | ||
assert.Nil(t, err) | ||
|
||
myString2, err := clipboard.ReadAll() | ||
assert.Nil(t, err) | ||
|
||
assert.Equal(t, myString, myString2) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ import ( | |
) | ||
|
||
func TestExecuteClienPsCmd(t *testing.T) { | ||
PsCmd.Execute() | ||
//runPsCmd() | ||
assert.Nil(t, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ import ( | |
) | ||
|
||
func TestExecuteClienRmCmd(t *testing.T) { | ||
RmCmd.Execute() | ||
//runRmCmd() | ||
assert.Nil(t, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,58 @@ | ||
package cmd | ||
|
||
import ( | ||
"crypto/rand" | ||
"encoding/hex" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/devcows/share/lib" | ||
"github.com/satori/go.uuid" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
var testSettings lib.SettingsShare | ||
|
||
func TempFilename(prefix string, extension string) string { | ||
randBytes := make([]byte, 16) | ||
rand.Read(randBytes) | ||
return filepath.Join(os.TempDir(), prefix+hex.EncodeToString(randBytes)+extension) | ||
} | ||
|
||
func setup() { | ||
testSettings = lib.NewSettings() | ||
testSettings.Daemon.DatabaseFilePath = TempFilename("db_", ".db") | ||
|
||
err := lib.InitDB(testSettings) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func shutdown() {} | ||
|
||
func TestMain(m *testing.M) { | ||
setup() | ||
code := m.Run() | ||
shutdown() | ||
os.Exit(code) | ||
} | ||
|
||
func TestExecuteServerCmd(t *testing.T) { | ||
go ServerCmd.Execute() | ||
assert.Nil(t, nil) | ||
configFile := TempFilename("config_", ".toml") | ||
|
||
err := lib.InitSettings(configFile, &testSettings) | ||
assert.Nil(t, err) | ||
|
||
err = lib.InitDB(testSettings) | ||
assert.Nil(t, err) | ||
|
||
server := lib.Server{UUID: uuid.NewV4().String(), Path: "MyString", Port: 1234, ListIps: []string{"1", "2"}, CreatedAt: time.Now()} | ||
err = lib.StoreServer(server) | ||
assert.Nil(t, err) | ||
|
||
err = runServerCmd(configFile, &testSettings) | ||
assert.Nil(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.