helper.go 778 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package framework
  2. import (
  3. "log"
  4. "strings"
  5. "github.com/robpike/filter"
  6. "github.com/onsi/gomega"
  7. )
  8. func nonEmptyString(s string) bool {
  9. return strings.TrimSpace(s) != ""
  10. }
  11. //Lines get lines from a raw string
  12. func Lines(output string) []string {
  13. return filter.Choose(strings.Split(output, "\n"), nonEmptyString).([]string)
  14. }
  15. //Columns get columns from a line
  16. func Columns(line string) []string {
  17. return filter.Choose(strings.Split(line, " "), nonEmptyString).([]string)
  18. }
  19. // It runs func
  20. func It(description string, test func()) {
  21. test()
  22. log.Print("Passed: ", description)
  23. }
  24. func gomegaFailHandler(message string, callerSkip ...int) {
  25. log.Fatal(message)
  26. }
  27. //SetupTest Init gomega fail handler
  28. func SetupTest() {
  29. gomega.RegisterFailHandler(gomegaFailHandler)
  30. }