owner_test.go 727 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package main
  2. import (
  3. "testing"
  4. "os"
  5. "fmt"
  6. )
  7. func TestOwnerPath(t *testing.T) {
  8. opts, _ = defaultOptions()
  9. p, err := ownerPath("testName")
  10. if err != nil {
  11. t.Error()
  12. }
  13. pwd, _ := os.Getwd()
  14. if pwd != p {
  15. t.Error()
  16. }
  17. opts.ClonePath = "test"
  18. p, err = ownerPath("nameToIgnore")
  19. fmt.Println(p)
  20. if p != "test" {
  21. t.Error()
  22. }
  23. }
  24. func TestNewOwner(t *testing.T) {
  25. opts, _ = defaultOptions()
  26. owner := newOwner()
  27. // default options will assume gitleaks is
  28. // running on local mode
  29. pwd, _ := os.Getwd()
  30. if pwd != owner.path {
  31. t.Error()
  32. }
  33. // fuck on this some more
  34. opts.URL = "github.com/testowner/test"
  35. owner = newOwner()
  36. fmt.Println(owner.path)
  37. if owner.path != pwd + "/testowner" {
  38. t.Error()
  39. }
  40. }