github.com/asifdxtreme/cli@v6.1.3-0.20150123051144-9ead8700b4ae+incompatible/cf/panic_printer/panic_printer_test.go (about)

     1  package panic_printer_test
     2  
     3  import (
     4  	"github.com/cloudfoundry/cli/cf"
     5  	. "github.com/cloudfoundry/cli/cf/panic_printer"
     6  	"github.com/cloudfoundry/cli/cf/terminal"
     7  	testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
     8  
     9  	. "github.com/onsi/ginkgo"
    10  	. "github.com/onsi/gomega"
    11  )
    12  
    13  var _ = Describe("Panic Printer", func() {
    14  	var ui *testterm.FakeUI
    15  
    16  	BeforeEach(func() {
    17  		UI = &testterm.FakeUI{}
    18  		ui = UI.(*testterm.FakeUI)
    19  	})
    20  
    21  	Describe("DisplayCrashDialog", func() {
    22  		Context("when given an err set to QuietPanic", func() {
    23  			It("should not print anything", func() {
    24  				err := terminal.QuietPanic
    25  				DisplayCrashDialog(err, "some command", "some trace")
    26  				Expect(len(ui.Outputs)).To(Equal(0))
    27  			})
    28  		})
    29  	})
    30  
    31  	Describe("CrashDialog", func() {
    32  		var errMsg = "this is an error"
    33  		var commandArgs = "command line arguments"
    34  		var stackTrace = "1000 bottles of beer"
    35  
    36  		It("should return a string containing the default error text", func() {
    37  			Expect(CrashDialog(errMsg, commandArgs, stackTrace)).To(ContainSubstring("Please file this bug : https://github.com/cloudfoundry/cli/issues"))
    38  		})
    39  
    40  		It("should return the command name", func() {
    41  			Expect(CrashDialog(errMsg, commandArgs, stackTrace)).To(ContainSubstring(cf.Name()))
    42  		})
    43  
    44  		It("should return the inputted arguments", func() {
    45  			Expect(CrashDialog(errMsg, commandArgs, stackTrace)).To(ContainSubstring("command line arguments"))
    46  		})
    47  
    48  		It("should return the specific error message", func() {
    49  			Expect(CrashDialog(errMsg, commandArgs, stackTrace)).To(ContainSubstring("this is an error"))
    50  		})
    51  
    52  		It("should return the stack trace", func() {
    53  			Expect(CrashDialog(errMsg, commandArgs, stackTrace)).To(ContainSubstring("1000 bottles of beer"))
    54  		})
    55  
    56  		It("should print the cli version", func() {
    57  			Expect(CrashDialog(errMsg, commandArgs, stackTrace)).To(ContainSubstring(cf.Version))
    58  		})
    59  	})
    60  })