-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support fallback attributions when generating codeowners file (#…
…145) * feat: support fallback attributions when generating codeowners file
- Loading branch information
1 parent
98c85f0
commit 35af4da
Showing
3 changed files
with
53 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,6 +1,12 @@ | ||
package codeowners | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/open-sauced/pizza-cli/pkg/config" | ||
) | ||
|
||
func TestCleanFilename(testRunner *testing.T) { | ||
var tests = []struct { | ||
|
@@ -27,3 +33,37 @@ func TestCleanFilename(testRunner *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestGetTopContributorAttributions(testRunner *testing.T) { | ||
configSpec := config.Spec{ | ||
Attributions: map[string][]string{ | ||
"brandonroberts": {"[email protected]"}, | ||
}, | ||
AttributionFallback: []string{"open-sauced/engineering"}, | ||
} | ||
|
||
var authorStats = AuthorStats{ | ||
"brandon": {GitHubAlias: "brandon", Email: "[email protected]", Lines: 20}, | ||
"john": {GitHubAlias: "john", Email: "[email protected]", Lines: 15}, | ||
} | ||
|
||
results := getTopContributorAttributions(authorStats, 3, &configSpec) | ||
|
||
assert.Equal(testRunner, len(results), 1, "Expected 1 result") | ||
assert.Equal(testRunner, results[0].GitHubAlias, "brandonroberts", "Expected brandonroberts") | ||
} | ||
|
||
func TestGetFallbackAttributions(testRunner *testing.T) { | ||
configSpec := config.Spec{ | ||
Attributions: map[string][]string{ | ||
"jpmcb": {"[email protected]"}, | ||
"brandonroberts": {"[email protected]"}, | ||
}, | ||
AttributionFallback: []string{"open-sauced/engineering"}, | ||
} | ||
|
||
results := getTopContributorAttributions(AuthorStats{}, 3, &configSpec) | ||
|
||
assert.Equal(testRunner, len(results), 1, "Expected 1 result") | ||
assert.Equal(testRunner, results[0].GitHubAlias, "open-sauced/engineering", "Expected open-sauced/engineering") | ||
} |
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 |
---|---|---|
|
@@ -8,4 +8,8 @@ type Spec struct { | |
// Example: { github_username: [ [email protected], [email protected] ]} where | ||
// "github_username" has 2 emails attributed to them and their work. | ||
Attributions map[string][]string `yaml:"attribution"` | ||
|
||
// AttributionFallback is the default username/group(s) to attribute to the filename | ||
// if no other attributions were found. | ||
AttributionFallback []string `yaml:"attribution-fallback"` | ||
} |