testing for install - in progress
This commit is contained in:
parent
6457ad290f
commit
7457bf0b93
7 changed files with 99 additions and 2 deletions
35
agent/agent_test.go
Normal file
35
agent/agent_test.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package agent
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func captureOutput(f func()) string {
|
||||
old := os.Stdout
|
||||
r, w, _ := os.Pipe()
|
||||
os.Stdout = w
|
||||
f()
|
||||
w.Close()
|
||||
os.Stdout = old
|
||||
|
||||
var buf bytes.Buffer
|
||||
io.Copy(&buf, r)
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
func TestShowStatus(t *testing.T) {
|
||||
var (
|
||||
version = "2.0.4"
|
||||
)
|
||||
|
||||
output := captureOutput(func() {
|
||||
ShowStatus(version)
|
||||
})
|
||||
|
||||
if output != (version + "\n") {
|
||||
t.Errorf("ShowStatus output not equal to version defined.")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue