-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package requirements | ||
|
||
import ( | ||
"github.com/gnolang/gno/contribs/github-bot/internal/utils" | ||
|
||
"github.com/google/go-github/v64/github" | ||
"github.com/xlab/treeprint" | ||
) | ||
|
||
// Draft Condition. | ||
type draft struct{} | ||
|
||
var _ Requirement = &draft{} | ||
|
||
func (*draft) IsSatisfied(pr *github.PullRequest, details treeprint.Tree) bool { | ||
return utils.AddStatusNode(pr.GetDraft(), "This pull request is a draft", details) | ||
} | ||
|
||
func Draft() Requirement { | ||
return &draft{} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package requirements | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/gnolang/gno/contribs/github-bot/internal/utils" | ||
"github.com/google/go-github/v64/github" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/xlab/treeprint" | ||
) | ||
|
||
func TestDraft(t *testing.T) { | ||
t.Parallel() | ||
|
||
for _, testCase := range []struct { | ||
name string | ||
isMet bool | ||
}{ | ||
{"draft is true", true}, | ||
{"draft is false", false}, | ||
} { | ||
t.Run(testCase.name, func(t *testing.T) { | ||
t.Parallel() | ||
|
||
pr := &github.PullRequest{Draft: &testCase.isMet} | ||
details := treeprint.New() | ||
req := Draft() | ||
|
||
assert.Equal(t, req.IsSatisfied(pr, details), testCase.isMet, fmt.Sprintf("condition should have a met status: %t", testCase.isMet)) | ||
assert.True(t, utils.TestLastNodeStatus(t, testCase.isMet, details), fmt.Sprintf("condition details should have a status: %t", testCase.isMet)) | ||
}) | ||
} | ||
} |