feat: show new updates in dashboard (#690)

* 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>
This commit is contained in:
ze0s 2023-02-05 18:44:11 +01:00 committed by GitHub
parent 3fdd7cf5e4
commit 2917a7d42d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 687 additions and 121 deletions

View file

@ -0,0 +1,55 @@
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)
}
})
}
}