Better interface for writeconfig
This commit is contained in:
parent
9d6cddb724
commit
06632c16da
2 changed files with 3 additions and 3 deletions
|
@ -22,7 +22,7 @@ type Config struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteConfigToFile writes a Config to a file
|
// WriteConfigToFile writes a Config to a file
|
||||||
func WriteConfigToFile(c *Config, filename string) error {
|
func (c *Config) WriteConfigToFile(filename string) error {
|
||||||
f, err := os.Create(filename)
|
f, err := os.Create(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -26,7 +26,7 @@ func TestNewConfig(t *testing.T) {
|
||||||
|
|
||||||
func TestWriteConfig(t *testing.T) {
|
func TestWriteConfig(t *testing.T) {
|
||||||
c := NewConfig()
|
c := NewConfig()
|
||||||
err := WriteConfigToFile(c, "test.toml")
|
err := c.WriteConfigToFile("test.toml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Expected no error, got %s", err)
|
t.Errorf("Expected no error, got %s", err)
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func TestWriteConfig(t *testing.T) {
|
||||||
|
|
||||||
func TestReadConfig(t *testing.T) {
|
func TestReadConfig(t *testing.T) {
|
||||||
c := NewConfig()
|
c := NewConfig()
|
||||||
err := WriteConfigToFile(c, "test.toml")
|
err := c.WriteConfigToFile("test.toml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Expected no error, got %s", err)
|
t.Errorf("Expected no error, got %s", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue