Skip to content

Commit

Permalink
Config package refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
vpoluyaktov committed Nov 6, 2023
1 parent 1fe6004 commit 1e56a3d
Show file tree
Hide file tree
Showing 20 changed files with 215 additions and 213 deletions.
28 changes: 14 additions & 14 deletions internal/audiobookshelf/audiobookshelf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (

func TestLogin(t *testing.T) {
config.Load()
url := config.AudiobookshelfUrl()
username := config.AudiobookshelfUser()
password := config.AudiobookshelfPassword()
url := config.Instance().GetAudiobookshelfUrl()
username := config.Instance().GetAudiobookshelfUser()
password := config.Instance().GetAudiobookshelfPassword()

if url != "" && username != "" && password != "" {
loginResp, err := audiobookshelf.Login(url+"/login", username, password)
Expand All @@ -25,15 +25,15 @@ func TestLogin(t *testing.T) {

func TestLibraries(t *testing.T) {
config.Load()
url := config.AudiobookshelfUrl()
username := config.AudiobookshelfUser()
password := config.AudiobookshelfPassword()
url := config.Instance().GetAudiobookshelfUrl()
username := config.Instance().GetAudiobookshelfUser()
password := config.Instance().GetAudiobookshelfPassword()

if url != "" && username != "" && password != "" {
loginResp, err := audiobookshelf.Login(url+"/login", username, password)
assert.NoError(t, err)
if err == nil {
libraryResponse , err := audiobookshelf.Libraries(url, loginResp.User.Token)
libraryResponse, err := audiobookshelf.Libraries(url, loginResp.User.Token)
assert.NoError(t, err)
assert.NotNil(t, libraryResponse)
assert.NotEmpty(t, libraryResponse.Libraries)
Expand All @@ -43,16 +43,16 @@ func TestLibraries(t *testing.T) {

func TestScan(t *testing.T) {
config.Load()
url := config.AudiobookshelfUrl()
username := config.AudiobookshelfUser()
password := config.AudiobookshelfPassword()
libraryName := config.AudiobookshelfLibrary()
url := config.Instance().GetAudiobookshelfUrl()
username := config.Instance().GetAudiobookshelfUser()
password := config.Instance().GetAudiobookshelfPassword()
libraryName := config.Instance().GetAudiobookshelfLibrary()

if url != "" && username != "" && password != "" && libraryName != "" {
if url != "" && username != "" && password != "" && libraryName != "" {
loginResp, err := audiobookshelf.Login(url+"/login", username, password)
if err == nil {
assert.NoError(t, err)
libraryResponse , err := audiobookshelf.Libraries(url, loginResp.User.Token)
libraryResponse, err := audiobookshelf.Libraries(url, loginResp.User.Token)
if err == nil {
assert.NoError(t, err)
libraryID, err := audiobookshelf.GetLibraryByName(libraryResponse.Libraries, libraryName)
Expand All @@ -65,4 +65,4 @@ func TestScan(t *testing.T) {
}
}
}
}
}
Loading

0 comments on commit 1e56a3d

Please sign in to comment.