mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00

* feat: show new update banner * feat(http): add request logger * refactor: updates checker * feat: make update check optional * fix: empty releases * add toggle switch for update checks * feat: toggle updates check from settings * feat: toggle updates check from settings * feat: check on toggle enabled --------- Co-authored-by: soup <soup@r4tio.dev>
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package config
|
|
|
|
import (
|
|
"reflect"
|
|
"sync"
|
|
"testing"
|
|
|
|
"github.com/autobrr/autobrr/internal/domain"
|
|
)
|
|
|
|
func TestAppConfig_processLines(t *testing.T) {
|
|
type fields struct {
|
|
Config *domain.Config
|
|
m sync.Mutex
|
|
}
|
|
type args struct {
|
|
lines []string
|
|
}
|
|
tests := []struct {
|
|
name string
|
|
fields fields
|
|
args args
|
|
want []string
|
|
}{
|
|
{
|
|
name: "append missing",
|
|
fields: fields{
|
|
Config: &domain.Config{CheckForUpdates: true},
|
|
m: sync.Mutex{},
|
|
},
|
|
args: args{[]string{}},
|
|
want: []string{"# Check for updates", "#", "checkForUpdates = true"},
|
|
},
|
|
{
|
|
name: "update existing",
|
|
fields: fields{
|
|
Config: &domain.Config{CheckForUpdates: true},
|
|
m: sync.Mutex{},
|
|
},
|
|
args: args{[]string{"# Check for updates", "#", "#checkForUpdates = false"}},
|
|
want: []string{"# Check for updates", "#", "checkForUpdates = true"},
|
|
},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
c := &AppConfig{
|
|
Config: tt.fields.Config,
|
|
m: tt.fields.m,
|
|
}
|
|
if got := c.processLines(tt.args.lines); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("processLines() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|