Skip to content

Commit

Permalink
test: updated tests for checking existing config file
Browse files Browse the repository at this point in the history
  • Loading branch information
nickytonline committed Sep 4, 2024
1 parent 33e1173 commit 09e0153
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 09e0153

Please sign in to comment.