review_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package command
  2. import (
  3. "fmt"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestCommandReviewedOwner(t *testing.T) {
  8. convey.Convey("ownerReviewed", t, func(ctx convey.C) {
  9. var (
  10. owners = []string{"a", "b"}
  11. reviewedUsers = []string{"a"}
  12. username = "d"
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. isowner, reviewed := reviewedOwner(owners, reviewedUsers, username)
  16. fmt.Println(isowner, reviewed)
  17. ctx.Convey("Then isowner,reviewed should not be nil.", func(ctx convey.C) {
  18. ctx.So(reviewed, convey.ShouldBeTrue)
  19. ctx.So(isowner, convey.ShouldBeFalse)
  20. })
  21. })
  22. })
  23. }
  24. func TestCommandReviewedNum(t *testing.T) {
  25. convey.Convey("reviewedNum", t, func(ctx convey.C) {
  26. var (
  27. reviewers = []string{"a", "b"}
  28. reviewedUsers = []string{"c"}
  29. )
  30. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  31. num := reviewedNum(reviewers, reviewedUsers)
  32. ctx.Convey("Then num should not be nil.", func(ctx convey.C) {
  33. ctx.So(num, convey.ShouldEqual, 0)
  34. })
  35. })
  36. })
  37. convey.Convey("reviewedNum", t, func(ctx convey.C) {
  38. var (
  39. reviewers = []string{"a", "b"}
  40. reviewedUsers = []string{"a"}
  41. )
  42. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  43. num := reviewedNum(reviewers, reviewedUsers)
  44. ctx.Convey("Then num should not be nil.", func(ctx convey.C) {
  45. ctx.So(num, convey.ShouldEqual, 1)
  46. })
  47. })
  48. })
  49. }