refactor: simplify codebase
This commit is contained in:
@@ -12,23 +12,11 @@ import (
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
const configFileName = "config.toml"
|
||||
|
||||
// Config is the user-owned TOML configuration for parasocial.
|
||||
type Config struct {
|
||||
Streamers []string `toml:"streamers"`
|
||||
}
|
||||
|
||||
// DefaultPath returns the config file path relative to the current working directory.
|
||||
func DefaultPath() string {
|
||||
return configFileName
|
||||
}
|
||||
|
||||
// LoadDefault reads config from the current working directory.
|
||||
func LoadDefault() (Config, error) {
|
||||
return Load(DefaultPath())
|
||||
}
|
||||
|
||||
// Load reads, normalizes, and validates a TOML config file.
|
||||
func Load(path string) (Config, error) {
|
||||
var cfg Config
|
||||
|
||||
@@ -46,12 +46,6 @@ func TestLoadRejectsInvalidTOML(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultPathUsesCurrentWorkingDirectoryConfig(t *testing.T) {
|
||||
if got := DefaultPath(); got != "config.toml" {
|
||||
t.Fatalf("DefaultPath() = %q, want %q", got, "config.toml")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRejectsMissingFile(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "missing.toml")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user