Change -config-dump to use KEY=VALUE format
This commit is contained in:
parent
72fbbe311a
commit
22bbe1ac50
2 changed files with 36 additions and 1 deletions
|
@ -1431,3 +1431,38 @@ func TestFetchYouTubeWatchTime(t *testing.T) {
|
|||
t.Fatalf(`Unexpected FETCH_YOUTUBE_WATCH_TIME value, got %v instead of %v`, result, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseConfigDumpOutput(t *testing.T) {
|
||||
os.Clearenv()
|
||||
|
||||
wantOpts := NewOptions()
|
||||
wantOpts.adminUsername = "my-username"
|
||||
|
||||
serialized := wantOpts.String()
|
||||
tmpfile, err := os.CreateTemp(".", "miniflux.*.unit_test.conf")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err := tmpfile.Write([]byte(serialized)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
parser := NewParser()
|
||||
parsedOpts, err := parser.ParseFile(tmpfile.Name())
|
||||
if err != nil {
|
||||
t.Errorf(`Parsing failure: %v`, err)
|
||||
}
|
||||
|
||||
if parsedOpts.AdminUsername() != wantOpts.AdminUsername() {
|
||||
t.Fatalf(`Unexpected ADMIN_USERNAME value, got %q instead of %q`, parsedOpts.AdminUsername(), wantOpts.AdminUsername())
|
||||
}
|
||||
|
||||
if err := tmpfile.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err := os.Remove(tmpfile.Name()); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -559,7 +559,7 @@ func (o *Options) String() string {
|
|||
var builder strings.Builder
|
||||
|
||||
for _, option := range o.SortedOptions() {
|
||||
builder.WriteString(fmt.Sprintf("%s: %v\n", option.Key, option.Value))
|
||||
fmt.Fprintf(&builder, "%s=%v\n", option.Key, option.Value)
|
||||
}
|
||||
|
||||
return builder.String()
|
||||
|
|
Loading…
Reference in a new issue