owner_test.go 607 B

123456789101112131415161718192021222324252627282930313233343536
  1. package main
  2. import (
  3. "os"
  4. "testing"
  5. )
  6. func TestOwnerPath(t *testing.T) {
  7. opts, _ = defaultOptions()
  8. p, err := ownerPath("testName")
  9. if err != nil {
  10. t.Error()
  11. }
  12. pwd, _ := os.Getwd()
  13. if pwd != p {
  14. t.Error()
  15. }
  16. opts.ClonePath = "gitleaksTestClonePath"
  17. p, err = ownerPath("nameToIgnore")
  18. if p != "gitleaksTestClonePath" {
  19. t.Error()
  20. }
  21. os.Remove("gitleaksTestClonePath")
  22. }
  23. func TestNewOwner(t *testing.T) {
  24. opts, _ = defaultOptions()
  25. owner := newOwner()
  26. // default options will assume gitleaks is
  27. // running on local mode
  28. pwd, _ := os.Getwd()
  29. if pwd != owner.path {
  30. t.Error()
  31. }
  32. }