contributors_test.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package command
  2. import (
  3. "fmt"
  4. "io/ioutil"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestCommandReadContributor(t *testing.T) {
  9. convey.Convey("readContributor", t, func(ctx convey.C) {
  10. content, _ := ioutil.ReadFile("../../CONTRIBUTORS.md")
  11. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  12. cc := readContributor(content)
  13. ctx.Convey("Then c should not be nil.", func(ctx convey.C) {
  14. ctx.So(fmt.Sprint(cc.Author), convey.ShouldEqual, `[muyang yubaihai wangweizhen wuwei]`)
  15. ctx.So(fmt.Sprint(cc.Owner), convey.ShouldEqual, `[muyang zhanglin]`)
  16. ctx.So(fmt.Sprint(cc.Reviewer), convey.ShouldEqual, `[muyang]`)
  17. })
  18. })
  19. })
  20. }
  21. func TestCommandHasBranch(t *testing.T) {
  22. convey.Convey("hasbranch", t, func(ctx convey.C) {
  23. var (
  24. branch = "test"
  25. branchs = []string{"master", "test"}
  26. )
  27. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  28. p1 := hasbranch(branch, branchs)
  29. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  30. ctx.So(p1, convey.ShouldEqual, true)
  31. })
  32. })
  33. })
  34. }