-
-
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.
test: updated tests for checking existing config file
- Loading branch information
1 parent
88da5df
commit d154027
Showing
1 changed file
with
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,30 @@ func TestLoadConfig(t *testing.T) { | |
t.Parallel() | ||
tmpDir := t.TempDir() | ||
configFilePath := filepath.Join(tmpDir, ".sauced.yaml") | ||
require.NoError(t, os.WriteFile(configFilePath, []byte("key: value"), 0644)) | ||
|
||
fileContents := `# Configuration for attributing commits with emails to GitHub user profiles | ||
# Used during codeowners generation. | ||
# List the emails associated with the given username. | ||
# The commits associated with these emails will be attributed to | ||
# the username in this yaml map. Any number of emails may be listed. | ||
attribution: | ||
brandonroberts: | ||
- [email protected] | ||
jpmcb: | ||
- [email protected]` | ||
|
||
require.NoError(t, os.WriteFile(configFilePath, []byte(fileContents), 0644)) | ||
|
||
config, err := LoadConfig(configFilePath, "") | ||
assert.NoError(t, err) | ||
assert.NotNil(t, config) | ||
|
||
// Assert that config contains all the Attributions in fileContents | ||
assert.Equal(t, 2, len(config.Attributions)) | ||
|
||
// Check specific attributions | ||
assert.Equal(t, []string{"[email protected]"}, config.Attributions["brandonroberts"]) | ||
assert.Equal(t, []string{"[email protected]"}, config.Attributions["jpmcb"]) | ||
}) | ||
|
||
t.Run("Non-existent file", func(t *testing.T) { | ||
|