bugsnag integration
Signed-off-by: Jean-Laurent de Morlhon <jeanlaurent@morlhon.net>
This commit is contained in:
@@ -78,11 +78,9 @@ func TestLocalBinaryPluginClose(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecServer(t *testing.T) {
|
||||
log.SetDebug(true)
|
||||
machineName := "test"
|
||||
|
||||
logReader, logWriter := io.Pipe()
|
||||
|
||||
log.SetDebug(true)
|
||||
log.SetOutput(logWriter)
|
||||
|
||||
defer func() {
|
||||
@@ -98,6 +96,7 @@ func TestExecServer(t *testing.T) {
|
||||
stderr: stderrReader,
|
||||
}
|
||||
|
||||
machineName := "test"
|
||||
lbp := &Plugin{
|
||||
MachineName: machineName,
|
||||
Executor: fe,
|
||||
@@ -112,12 +111,10 @@ func TestExecServer(t *testing.T) {
|
||||
finalErr <- lbp.execServer()
|
||||
}()
|
||||
|
||||
expectedAddr := "127.0.0.1:12345"
|
||||
expectedPluginOut := "Doing some fun plugin stuff..."
|
||||
expectedPluginErr := "Uh oh, something in plugin went wrong..."
|
||||
|
||||
logScanner := bufio.NewScanner(logReader)
|
||||
|
||||
// Write the ip address
|
||||
expectedAddr := "127.0.0.1:12345"
|
||||
if _, err := io.WriteString(stdoutWriter, expectedAddr+"\n"); err != nil {
|
||||
t.Fatalf("Error attempting to write plugin address: %s", err)
|
||||
}
|
||||
@@ -126,22 +123,24 @@ func TestExecServer(t *testing.T) {
|
||||
t.Fatalf("Expected to read the expected address properly in server but did not")
|
||||
}
|
||||
|
||||
expectedOut := fmt.Sprintf("%s%s", fmt.Sprintf(pluginOutPrefix, machineName), expectedPluginOut)
|
||||
|
||||
// Write a log in stdout
|
||||
expectedPluginOut := "Doing some fun plugin stuff..."
|
||||
if _, err := io.WriteString(stdoutWriter, expectedPluginOut+"\n"); err != nil {
|
||||
t.Fatalf("Error attempting to write to out in plugin: %s", err)
|
||||
}
|
||||
|
||||
expectedOut := fmt.Sprintf(pluginOut, machineName, expectedPluginOut)
|
||||
if logScanner.Scan(); logScanner.Text() != expectedOut {
|
||||
t.Fatalf("Output written to log was not what we expected\nexpected: %s\nactual: %s", expectedOut, logScanner.Text())
|
||||
}
|
||||
|
||||
expectedErr := fmt.Sprintf("%s%s", fmt.Sprintf(pluginErrPrefix, machineName), expectedPluginErr)
|
||||
|
||||
// Write a log in stderr
|
||||
expectedPluginErr := "Uh oh, something in plugin went wrong..."
|
||||
if _, err := io.WriteString(stderrWriter, expectedPluginErr+"\n"); err != nil {
|
||||
t.Fatalf("Error attempting to write to err in plugin: %s", err)
|
||||
}
|
||||
|
||||
expectedErr := fmt.Sprintf(pluginErr, machineName, expectedPluginErr)
|
||||
if logScanner.Scan(); logScanner.Text() != expectedErr {
|
||||
t.Fatalf("Error written to log was not what we expected\nexpected: %s\nactual: %s", expectedErr, logScanner.Text())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user