...

Source file src/gotest.tools/v3/icmd/example_test.go

Documentation: gotest.tools/v3/icmd

     1  package icmd_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"gotest.tools/v3/icmd"
     7  )
     8  
     9  var t = &testing.T{}
    10  
    11  func ExampleRunCommand() {
    12  	result := icmd.RunCommand("bash", "-c", "echo all good")
    13  	result.Assert(t, icmd.Success)
    14  }
    15  
    16  func ExampleRunCmd() {
    17  	result := icmd.RunCmd(icmd.Command("cat", "/does/not/exist"))
    18  	result.Assert(t, icmd.Expected{
    19  		ExitCode: 1,
    20  		Err:      "cat: /does/not/exist: No such file or directory",
    21  	})
    22  }
    23  

View as plain text