...

Source file src/github.com/redhat-developer/odo/tests/helper/helper_logs.go

Documentation: github.com/redhat-developer/odo/tests/helper

     1  package helper
     2  
     3  import (
     4  	"github.com/onsi/gomega/gexec"
     5  )
     6  
     7  type LogsSession struct {
     8  	session *gexec.Session
     9  }
    10  
    11  // StartLogsFollow starts a session with `odo logs --follow`
    12  // It returns a session structure, the contents of the standard and error outputs
    13  func StartLogsFollow(podman bool, opts ...string) (LogsSession, []byte, []byte, error) {
    14  	args := []string{"logs", "--follow"}
    15  	args = append(args, opts...)
    16  	if podman {
    17  		args = append(args, "--platform", "podman")
    18  	}
    19  	session := CmdRunner("odo", args...)
    20  
    21  	result := LogsSession{
    22  		session: session,
    23  	}
    24  	outContents := session.Out.Contents()
    25  	errContents := session.Err.Contents()
    26  	err := session.Out.Clear()
    27  	if err != nil {
    28  		return LogsSession{}, nil, nil, err
    29  	}
    30  	err = session.Err.Clear()
    31  	if err != nil {
    32  		return LogsSession{}, nil, nil, err
    33  	}
    34  	return result, outContents, errContents, nil
    35  }
    36  
    37  // OutContents returns the contents of the session's stdout
    38  func (o *LogsSession) OutContents() []byte {
    39  	return o.session.Out.Contents()
    40  }
    41  
    42  // Kill the `odo logs --follow` session
    43  func (o *LogsSession) Kill() {
    44  	o.session.Kill()
    45  }
    46  

View as plain text