forked from lgtmco/lgtm
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request lgtmco#2 from jonbodner/fix_orgs
Add unit test, find and fix bugs in org detection.
- Loading branch information
Showing
2 changed files
with
82 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package org | ||
|
||
import ( | ||
"testing" | ||
"github.com/lgtmco/lgtm/model" | ||
) | ||
|
||
var maintainerToml = ` | ||
[people] | ||
[people.bob] | ||
login = "bob" | ||
[people.fred] | ||
login = "fred" | ||
[people.jon] | ||
login = "jon" | ||
[people.ralph] | ||
login = "ralph" | ||
[people.george] | ||
login = "george" | ||
[org] | ||
[org.cap] | ||
people = [ | ||
"bob", | ||
"fred", | ||
"jon" | ||
] | ||
[org.iron] | ||
people = [ | ||
"ralph", | ||
"george" | ||
] | ||
` | ||
|
||
func TestOrg(t *testing.T) { | ||
config := &model.Config { | ||
Pattern: `(?i)LGTM\s*(\S*)`, | ||
SelfApprovalOff: true, | ||
} | ||
m, err := model.ParseMaintainerStr(maintainerToml) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
issue := &model.Issue{ | ||
Author: "jon", | ||
} | ||
comments := []*model.Comment { | ||
{ | ||
Body: "lgtm", | ||
Author: "bob", | ||
}, | ||
{ | ||
Body: "lgtm", | ||
Author: "qwerty", | ||
}, | ||
{ | ||
Body: "not an approval", | ||
Author: "ralph", | ||
}, | ||
{ | ||
Body: "lgtm", | ||
Author: "george", | ||
}, | ||
{ | ||
Body: "lgtm", | ||
Author: "ralph", | ||
}, | ||
} | ||
people := []string{} | ||
Org(config, m, issue, comments, func(m *model.Maintainer, c *model.Comment) { | ||
people = append(people, c.Author) | ||
}) | ||
if len(people) != 1 { | ||
t.Errorf("Expected one person, had %d", len(people)) | ||
} | ||
if people[0] != "george" { | ||
t.Errorf("Expected george, had %s", people[0]) | ||
} | ||
} |