diff --git a/go.mod b/go.mod index 7b21aa2..a9b5351 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/jinzhu/gorm v1.9.2 github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect github.com/jinzhu/now v1.0.0 // indirect + github.com/josephburnett/jd v0.0.0-20190523064723-9cd4cea55d7d github.com/karrick/godirwalk v1.8.0 github.com/lib/pq v1.0.0 // indirect github.com/mattn/go-sqlite3 v1.10.0 // indirect diff --git a/go.sum b/go.sum index aa34f0d..a9bc273 100644 --- a/go.sum +++ b/go.sum @@ -107,6 +107,8 @@ github.com/jinzhu/now v1.0.0 h1:6WV8LvwPpDhKjo5U9O6b4+xdG/jTXNPwlDme/MTo8Ns= github.com/jinzhu/now v1.0.0/go.mod h1:oHTiXerJ20+SfYcrdlBO7rzZRJWGwSTQ0iUY2jI6Gfc= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/josephburnett/jd v0.0.0-20190523064723-9cd4cea55d7d h1:PYUR84NZE+Tm2jkGt85mUFVyXv27rDhLpLa3WBhJOog= +github.com/josephburnett/jd v0.0.0-20190523064723-9cd4cea55d7d/go.mod h1:aeV+6oc13ogwzcRNHBe4vbyLmoQxMfEDoqyqCU9oE30= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/karrick/godirwalk v1.8.0 h1:ycpSqVon/QJJoaT1t8sae0tp1Stg21j+dyuS7OoagcA= diff --git a/server/handler/handler_sub_by_folder_test.go b/server/handler/handler_sub_by_folder_test.go new file mode 100644 index 0000000..803be0d --- /dev/null +++ b/server/handler/handler_sub_by_folder_test.go @@ -0,0 +1,38 @@ +package handler + +import ( + "net/url" + "testing" + + _ "github.com/jinzhu/gorm/dialects/sqlite" +) + +func TestGetIndexes(t *testing.T) { + testQueryCases(t, testController.GetIndexes, []*queryCase{ + {url.Values{"id": []string{"2"}}, "id_two", false}, + }) +} + +func TestGetMusicDirectory(t *testing.T) { + testQueryCases(t, testController.GetMusicDirectory, []*queryCase{ + {url.Values{"id": []string{"2"}}, "without_tracks", false}, + {url.Values{"id": []string{"3"}}, "with_tracks", false}, + }) +} + +func TestGetAlbumList(t *testing.T) { + testQueryCases(t, testController.GetAlbumList, []*queryCase{ + {url.Values{"type": []string{"alphabeticalByArtist"}}, "alpha_artist", false}, + {url.Values{"type": []string{"alphabeticalByName"}}, "alpha_name", false}, + {url.Values{"type": []string{"newest"}}, "newest", false}, + {url.Values{"type": []string{"random"}}, "random", true}, + }) +} + +func TestSearchTwo(t *testing.T) { + testQueryCases(t, testController.SearchTwo, []*queryCase{ + {url.Values{"query": []string{"13"}}, "q_13", false}, + {url.Values{"query": []string{"ani"}}, "q_ani", false}, + {url.Values{"query": []string{"cert"}}, "q_cert", false}, + }) +} diff --git a/server/handler/handler_sub_by_tags_test.go b/server/handler/handler_sub_by_tags_test.go new file mode 100644 index 0000000..b1e72a8 --- /dev/null +++ b/server/handler/handler_sub_by_tags_test.go @@ -0,0 +1,44 @@ +package handler + +import ( + "net/url" + "testing" +) + +func TestGetArtists(t *testing.T) { + testQueryCases(t, testController.GetArtists, []*queryCase{ + {url.Values{}, "no_args", false}, + }) +} + +func TestGetArtist(t *testing.T) { + testQueryCases(t, testController.GetArtist, []*queryCase{ + {url.Values{"id": []string{"1"}}, "id_one", false}, + {url.Values{"id": []string{"2"}}, "id_two", false}, + {url.Values{"id": []string{"3"}}, "id_three", false}, + }) +} + +func TestGetAlbum(t *testing.T) { + testQueryCases(t, testController.GetAlbum, []*queryCase{ + {url.Values{"id": []string{"2"}}, "without_cover", false}, + {url.Values{"id": []string{"3"}}, "with_cover", false}, + }) +} + +func TestGetAlbumListTwo(t *testing.T) { + testQueryCases(t, testController.GetAlbumListTwo, []*queryCase{ + {url.Values{"type": []string{"alphabeticalByArtist"}}, "alpha_artist", false}, + {url.Values{"type": []string{"alphabeticalByName"}}, "alpha_name", false}, + {url.Values{"type": []string{"newest"}}, "newest", false}, + {url.Values{"type": []string{"random"}}, "random", true}, + }) +} + +func TestSearchThree(t *testing.T) { + testQueryCases(t, testController.SearchThree, []*queryCase{ + {url.Values{"query": []string{"13"}}, "q_13", false}, + {url.Values{"query": []string{"ani"}}, "q_ani", false}, + {url.Values{"query": []string{"cert"}}, "q_cert", false}, + }) +} diff --git a/server/handler/handler_test.go b/server/handler/handler_test.go new file mode 100644 index 0000000..18acdb5 --- /dev/null +++ b/server/handler/handler_test.go @@ -0,0 +1,78 @@ +package handler + +import ( + "log" + "net/http" + "net/http/httptest" + "net/url" + "path" + "regexp" + "strings" + "testing" + + "github.com/jinzhu/gorm" + jd "github.com/josephburnett/jd/lib" +) + +var ( + testController *Controller + testDataDir = "test_data" + testCamelExpr = regexp.MustCompile("([a-z0-9])([A-Z])") +) + +func init() { + testDBPath := path.Join(testDataDir, "db") + testDB, err := gorm.Open("sqlite3", testDBPath) + if err != nil { + log.Fatalf("error opening database: %v\n", err) + } + testController = &Controller{DB: testDB} +} + +type queryCase struct { + params url.Values + expectPath string + listSet bool +} + +func testNameToPath(name string) string { + snake := testCamelExpr.ReplaceAllString(name, "${1}_${2}") + lower := strings.ToLower(snake) + relPath := strings.Replace(lower, "/", "_", -1) + return path.Join(testDataDir, relPath) +} + +func testQueryCases(t *testing.T, handler http.HandlerFunc, cases []*queryCase) { + for _, qc := range cases { + t.Run(qc.expectPath, func(t *testing.T) { + // ensure the handlers give us json + qc.params.Add("f", "json") + req, _ := http.NewRequest("", "?"+qc.params.Encode(), nil) + rr := httptest.NewRecorder() + handler.ServeHTTP(rr, req) + body := rr.Body.String() + if status := rr.Code; status != http.StatusOK { + t.Fatalf("didn't give a 200\n%s", body) + } + absExpPath := testNameToPath(t.Name()) + expected, err := jd.ReadJsonFile(absExpPath) + if err != nil { + t.Fatalf("parsing expected: %v", err) + } + actual, _ := jd.ReadJsonString(body) + if err != nil { + t.Fatalf("parsing actual: %v", err) + } + diffOpts := []jd.Metadata{} + if qc.listSet { + diffOpts = append(diffOpts, jd.SET) + } + diff := expected.Diff(actual, diffOpts...) + if len(diff) == 0 { + return + } + t.Errorf("\u001b[31;1mdiffering json\u001b[0m\n%s", + diff.Render()) + }) + } +} diff --git a/server/handler/test_data/db b/server/handler/test_data/db new file mode 100644 index 0000000..08b6859 Binary files /dev/null and b/server/handler/test_data/db differ diff --git a/server/handler/test_data/test_get_album_list_alpha_artist b/server/handler/test_data/test_get_album_list_alpha_artist new file mode 100644 index 0000000..6f839ef --- /dev/null +++ b/server/handler/test_data/test_get_album_list_alpha_artist @@ -0,0 +1,54 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "albumList": { + "album": [ + { + "id": 6, + "coverArt": 2, + "artist": "13th Floor Lowervators", + "title": "(1967) Easter Nowhere", + "parent": 5, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 7, + "coverArt": 3, + "artist": "13th Floor Lowervators", + "title": "(1966) The Psychedelic Sounds of the 13th Floor Elevators", + "parent": 5, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 3, + "coverArt": 1, + "artist": "A Certain Ratio", + "title": "(1994) The Graveyard and the Ballroom", + "parent": 2, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 4, + "artist": "A Certain Ratio", + "title": "(1981) To Each.", + "parent": 2, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 11, + "coverArt": 4, + "artist": "There", + "title": "(2010) Anika", + "parent": 10, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_album_list_alpha_name b/server/handler/test_data/test_get_album_list_alpha_name new file mode 100644 index 0000000..bf4aa19 --- /dev/null +++ b/server/handler/test_data/test_get_album_list_alpha_name @@ -0,0 +1,54 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "albumList": { + "album": [ + { + "id": 7, + "coverArt": 3, + "artist": "13th Floor Lowervators", + "title": "(1966) The Psychedelic Sounds of the 13th Floor Elevators", + "parent": 5, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 6, + "coverArt": 2, + "artist": "13th Floor Lowervators", + "title": "(1967) Easter Nowhere", + "parent": 5, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 4, + "artist": "A Certain Ratio", + "title": "(1981) To Each.", + "parent": 2, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 3, + "coverArt": 1, + "artist": "A Certain Ratio", + "title": "(1994) The Graveyard and the Ballroom", + "parent": 2, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 11, + "coverArt": 4, + "artist": "There", + "title": "(2010) Anika", + "parent": 10, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_album_list_newest b/server/handler/test_data/test_get_album_list_newest new file mode 100644 index 0000000..d862150 --- /dev/null +++ b/server/handler/test_data/test_get_album_list_newest @@ -0,0 +1,54 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "albumList": { + "album": [ + { + "id": 11, + "coverArt": 4, + "artist": "There", + "title": "(2010) Anika", + "parent": 10, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 7, + "coverArt": 3, + "artist": "13th Floor Lowervators", + "title": "(1966) The Psychedelic Sounds of the 13th Floor Elevators", + "parent": 5, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 6, + "coverArt": 2, + "artist": "13th Floor Lowervators", + "title": "(1967) Easter Nowhere", + "parent": 5, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 4, + "artist": "A Certain Ratio", + "title": "(1981) To Each.", + "parent": 2, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 3, + "coverArt": 1, + "artist": "A Certain Ratio", + "title": "(1994) The Graveyard and the Ballroom", + "parent": 2, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_album_list_random b/server/handler/test_data/test_get_album_list_random new file mode 100644 index 0000000..4da4f24 --- /dev/null +++ b/server/handler/test_data/test_get_album_list_random @@ -0,0 +1,54 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "albumList": { + "album": [ + { + "id": 11, + "coverArt": 4, + "artist": "There", + "title": "(2010) Anika", + "parent": 10, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 6, + "coverArt": 2, + "artist": "13th Floor Lowervators", + "title": "(1967) Easter Nowhere", + "parent": 5, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 4, + "artist": "A Certain Ratio", + "title": "(1981) To Each.", + "parent": 2, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 3, + "coverArt": 1, + "artist": "A Certain Ratio", + "title": "(1994) The Graveyard and the Ballroom", + "parent": 2, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + }, + { + "id": 7, + "coverArt": 3, + "artist": "13th Floor Lowervators", + "title": "(1966) The Psychedelic Sounds of the 13th Floor Elevators", + "parent": 5, + "isDir": true, + "created": "0001-01-01T00:00:00Z" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_album_list_two_alpha_artist b/server/handler/test_data/test_get_album_list_two_alpha_artist new file mode 100644 index 0000000..ca74905 --- /dev/null +++ b/server/handler/test_data/test_get_album_list_two_alpha_artist @@ -0,0 +1,49 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "albumList2": { + "album": [ + { + "id": 3, + "coverArt": 2, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "Easter Everywhere", + "created": "2019-05-28T20:59:03.010415595+01:00" + }, + { + "id": 4, + "coverArt": 3, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "The Psychedelic Sounds of the 13th Floor Elevators", + "created": "2019-05-28T20:59:03.022922683+01:00" + }, + { + "id": 1, + "coverArt": 1, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "The Graveyard and the Ballroom", + "created": "2019-05-28T20:59:02.988372626+01:00" + }, + { + "id": 2, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "To Each...", + "created": "2019-05-28T20:59:02.995320471+01:00" + }, + { + "id": 5, + "coverArt": 4, + "artistId": 3, + "artist": "Anikas", + "name": "Anika", + "created": "2019-05-28T20:59:03.035442597+01:00" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_album_list_two_alpha_name b/server/handler/test_data/test_get_album_list_two_alpha_name new file mode 100644 index 0000000..7e02e2f --- /dev/null +++ b/server/handler/test_data/test_get_album_list_two_alpha_name @@ -0,0 +1,49 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "albumList2": { + "album": [ + { + "id": 5, + "coverArt": 4, + "artistId": 3, + "artist": "Anikas", + "name": "Anika", + "created": "2019-05-28T20:59:03.035442597+01:00" + }, + { + "id": 3, + "coverArt": 2, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "Easter Everywhere", + "created": "2019-05-28T20:59:03.010415595+01:00" + }, + { + "id": 1, + "coverArt": 1, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "The Graveyard and the Ballroom", + "created": "2019-05-28T20:59:02.988372626+01:00" + }, + { + "id": 4, + "coverArt": 3, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "The Psychedelic Sounds of the 13th Floor Elevators", + "created": "2019-05-28T20:59:03.022922683+01:00" + }, + { + "id": 2, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "To Each...", + "created": "2019-05-28T20:59:02.995320471+01:00" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_album_list_two_newest b/server/handler/test_data/test_get_album_list_two_newest new file mode 100644 index 0000000..2176136 --- /dev/null +++ b/server/handler/test_data/test_get_album_list_two_newest @@ -0,0 +1,49 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "albumList2": { + "album": [ + { + "id": 5, + "coverArt": 4, + "artistId": 3, + "artist": "Anikas", + "name": "Anika", + "created": "2019-05-28T20:59:03.035442597+01:00" + }, + { + "id": 4, + "coverArt": 3, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "The Psychedelic Sounds of the 13th Floor Elevators", + "created": "2019-05-28T20:59:03.022922683+01:00" + }, + { + "id": 3, + "coverArt": 2, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "Easter Everywhere", + "created": "2019-05-28T20:59:03.010415595+01:00" + }, + { + "id": 2, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "To Each...", + "created": "2019-05-28T20:59:02.995320471+01:00" + }, + { + "id": 1, + "coverArt": 1, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "The Graveyard and the Ballroom", + "created": "2019-05-28T20:59:02.988372626+01:00" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_album_list_two_random b/server/handler/test_data/test_get_album_list_two_random new file mode 100644 index 0000000..071cef6 --- /dev/null +++ b/server/handler/test_data/test_get_album_list_two_random @@ -0,0 +1,49 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "albumList2": { + "album": [ + { + "id": 4, + "coverArt": 3, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "The Psychedelic Sounds of the 13th Floor Elevators", + "created": "2019-05-28T20:59:03.022922683+01:00" + }, + { + "id": 5, + "coverArt": 4, + "artistId": 3, + "artist": "Anikas", + "name": "Anika", + "created": "2019-05-28T20:59:03.035442597+01:00" + }, + { + "id": 1, + "coverArt": 1, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "The Graveyard and the Ballroom", + "created": "2019-05-28T20:59:02.988372626+01:00" + }, + { + "id": 3, + "coverArt": 2, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "Easter Everywhere", + "created": "2019-05-28T20:59:03.010415595+01:00" + }, + { + "id": 2, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "To Each...", + "created": "2019-05-28T20:59:02.995320471+01:00" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_album_with_cover b/server/handler/test_data/test_get_album_with_cover new file mode 100644 index 0000000..3f128b4 --- /dev/null +++ b/server/handler/test_data/test_get_album_with_cover @@ -0,0 +1,186 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "album": { + "id": 3, + "coverArt": 2, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "Easter Everywhere", + "created": "2019-05-28T20:59:03.010415595+01:00", + "song": [ + { + "album": "Easter Everywhere", + "albumId": 3, + "artist": "13th Floor Elevators", + "artistId": 2, + "contentType": "audio/x-flac", + "coverArt": 2, + "created": "2019-05-28T20:59:03.01067974+01:00", + "id": 25, + "parent": 6, + "path": "13th Floor Lowervators/(1967) Easter Nowhere/01.10 Slip Inside This House.flac", + "size": 52229000, + "suffix": "flac", + "title": "Slip Inside This House", + "track": 1, + "type": "music" + }, + { + "album": "Easter Everywhere", + "albumId": 3, + "artist": "13th Floor Elevators", + "artistId": 2, + "contentType": "audio/x-flac", + "coverArt": 2, + "created": "2019-05-28T20:59:03.010814449+01:00", + "id": 27, + "parent": 6, + "path": "13th Floor Lowervators/(1967) Easter Nowhere/02.10 Slide Machine.flac", + "size": 22964562, + "suffix": "flac", + "title": "Slide Machine", + "track": 2, + "type": "music" + }, + { + "album": "Easter Everywhere", + "albumId": 3, + "artist": "13th Floor Elevators", + "artistId": 2, + "contentType": "audio/x-flac", + "coverArt": 2, + "created": "2019-05-28T20:59:03.010880444+01:00", + "id": 28, + "parent": 6, + "path": "13th Floor Lowervators/(1967) Easter Nowhere/03.10 She Lives (In a Time of Her Own).flac", + "size": 18474888, + "suffix": "flac", + "title": "She Lives (In a Time of Her Own)", + "track": 3, + "type": "music" + }, + { + "album": "Easter Everywhere", + "albumId": 3, + "artist": "13th Floor Elevators", + "artistId": 2, + "contentType": "audio/x-flac", + "coverArt": 2, + "created": "2019-05-28T20:59:03.011044654+01:00", + "id": 30, + "parent": 6, + "path": "13th Floor Lowervators/(1967) Easter Nowhere/04.10 Nobody to Love.flac", + "size": 18067448, + "suffix": "flac", + "title": "Nobody to Love", + "track": 4, + "type": "music" + }, + { + "album": "Easter Everywhere", + "albumId": 3, + "artist": "13th Floor Elevators", + "artistId": 2, + "contentType": "audio/x-flac", + "coverArt": 2, + "created": "2019-05-28T20:59:03.011106774+01:00", + "id": 31, + "parent": 6, + "path": "13th Floor Lowervators/(1967) Easter Nowhere/05.10 Baby Blue.flac", + "size": 31828836, + "suffix": "flac", + "title": "Baby Blue", + "track": 5, + "type": "music" + }, + { + "album": "Easter Everywhere", + "albumId": 3, + "artist": "13th Floor Elevators", + "artistId": 2, + "contentType": "audio/x-flac", + "coverArt": 2, + "created": "2019-05-28T20:59:03.011174899+01:00", + "id": 32, + "parent": 6, + "path": "13th Floor Lowervators/(1967) Easter Nowhere/06.10 Earthquake.flac", + "size": 29066645, + "suffix": "flac", + "title": "Earthquake", + "track": 6, + "type": "music" + }, + { + "album": "Easter Everywhere", + "albumId": 3, + "artist": "13th Floor Elevators", + "artistId": 2, + "contentType": "audio/x-flac", + "coverArt": 2, + "created": "2019-05-28T20:59:03.010597689+01:00", + "id": 24, + "parent": 6, + "path": "13th Floor Lowervators/(1967) Easter Nowhere/07.10 Dust.flac", + "size": 22652796, + "suffix": "flac", + "title": "Dust", + "track": 7, + "type": "music" + }, + { + "album": "Easter Everywhere", + "albumId": 3, + "artist": "13th Floor Elevators", + "artistId": 2, + "contentType": "audio/x-flac", + "coverArt": 2, + "created": "2019-05-28T20:59:03.010749083+01:00", + "id": 26, + "parent": 6, + "path": "13th Floor Lowervators/(1967) Easter Nowhere/08.10 Levitation.flac", + "size": 16354677, + "suffix": "flac", + "title": "Levitation", + "track": 8, + "type": "music" + }, + { + "album": "Easter Everywhere", + "albumId": 3, + "artist": "13th Floor Elevators", + "artistId": 2, + "contentType": "audio/x-flac", + "coverArt": 2, + "created": "2019-05-28T20:59:03.011238025+01:00", + "id": 33, + "parent": 6, + "path": "13th Floor Lowervators/(1967) Easter Nowhere/09.10 I Had to Tell You.flac", + "size": 14261007, + "suffix": "flac", + "title": "I Had to Tell You", + "track": 9, + "type": "music" + }, + { + "album": "Easter Everywhere", + "albumId": 3, + "artist": "13th Floor Elevators", + "artistId": 2, + "contentType": "audio/x-flac", + "coverArt": 2, + "created": "2019-05-28T20:59:03.010949903+01:00", + "id": 29, + "parent": 6, + "path": "13th Floor Lowervators/(1967) Easter Nowhere/10.10 Pictures (Leave Your Body Behind).flac", + "size": 39529576, + "suffix": "flac", + "title": "Pictures (Leave Your Body Behind)", + "track": 10, + "type": "music" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_album_without_cover b/server/handler/test_data/test_get_album_without_cover new file mode 100644 index 0000000..b4d8404 --- /dev/null +++ b/server/handler/test_data/test_get_album_without_cover @@ -0,0 +1,159 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "album": { + "id": 2, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "To Each...", + "created": "2019-05-28T20:59:02.995320471+01:00", + "song": [ + { + "album": "To Each...", + "albumId": 2, + "artist": "A Certain Ratio", + "artistId": 1, + "contentType": "audio/x-flac", + "created": "2019-05-28T20:59:02.99562727+01:00", + "id": 16, + "parent": 4, + "path": "A Certain Ratio/(1981) To Each./01.09 Felch.flac", + "size": 24708838, + "suffix": "flac", + "title": "Felch", + "track": 1, + "type": "music" + }, + { + "album": "To Each...", + "albumId": 2, + "artist": "A Certain Ratio", + "artistId": 1, + "contentType": "audio/x-flac", + "created": "2019-05-28T20:59:02.995889638+01:00", + "id": 20, + "parent": 4, + "path": "A Certain Ratio/(1981) To Each./02.09 My Spirit.flac", + "size": 17102404, + "suffix": "flac", + "title": "My Spirit", + "track": 2, + "type": "music" + }, + { + "album": "To Each...", + "albumId": 2, + "artist": "A Certain Ratio", + "artistId": 1, + "contentType": "audio/x-flac", + "created": "2019-05-28T20:59:02.99609285+01:00", + "id": 23, + "parent": 4, + "path": "A Certain Ratio/(1981) To Each./03.09 Forced Laugh.flac", + "size": 37924980, + "suffix": "flac", + "title": "Forced Laugh", + "track": 3, + "type": "music" + }, + { + "album": "To Each...", + "albumId": 2, + "artist": "A Certain Ratio", + "artistId": 1, + "contentType": "audio/x-flac", + "created": "2019-05-28T20:59:02.995953401+01:00", + "id": 21, + "parent": 4, + "path": "A Certain Ratio/(1981) To Each./04.09 Choir.flac", + "size": 21205583, + "suffix": "flac", + "title": "Choir", + "track": 4, + "type": "music" + }, + { + "album": "To Each...", + "albumId": 2, + "artist": "A Certain Ratio", + "artistId": 1, + "contentType": "audio/x-flac", + "created": "2019-05-28T20:59:02.99569934+01:00", + "id": 17, + "parent": 4, + "path": "A Certain Ratio/(1981) To Each./05.09 Back to the Start.flac", + "size": 56733069, + "suffix": "flac", + "title": "Back to the Start", + "track": 5, + "type": "music" + }, + { + "album": "To Each...", + "albumId": 2, + "artist": "A Certain Ratio", + "artistId": 1, + "contentType": "audio/x-flac", + "created": "2019-05-28T20:59:02.995826449+01:00", + "id": 19, + "parent": 4, + "path": "A Certain Ratio/(1981) To Each./06.09 The Fox.flac", + "size": 26835335, + "suffix": "flac", + "title": "The Fox", + "track": 6, + "type": "music" + }, + { + "album": "To Each...", + "albumId": 2, + "artist": "A Certain Ratio", + "artistId": 1, + "contentType": "audio/x-flac", + "created": "2019-05-28T20:59:02.995544892+01:00", + "id": 15, + "parent": 4, + "path": "A Certain Ratio/(1981) To Each./07.09 Loss.flac", + "size": 20494369, + "suffix": "flac", + "title": "Loss", + "track": 7, + "type": "music" + }, + { + "album": "To Each...", + "albumId": 2, + "artist": "A Certain Ratio", + "artistId": 1, + "contentType": "audio/x-flac", + "created": "2019-05-28T20:59:02.995761233+01:00", + "id": 18, + "parent": 4, + "path": "A Certain Ratio/(1981) To Each./08.09 Oceans.flac", + "size": 25233096, + "suffix": "flac", + "title": "Oceans", + "track": 8, + "type": "music" + }, + { + "album": "To Each...", + "albumId": 2, + "artist": "A Certain Ratio", + "artistId": 1, + "contentType": "audio/x-flac", + "created": "2019-05-28T20:59:02.99603217+01:00", + "id": 22, + "parent": 4, + "path": "A Certain Ratio/(1981) To Each./09.09 Winter Hill.flac", + "size": 89483446, + "suffix": "flac", + "title": "Winter Hill", + "track": 9, + "type": "music" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_artist_id_one b/server/handler/test_data/test_get_artist_id_one new file mode 100644 index 0000000..44785a5 --- /dev/null +++ b/server/handler/test_data/test_get_artist_id_one @@ -0,0 +1,27 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "artist": { + "id": 1, + "name": "A Certain Ratio", + "album": [ + { + "id": 1, + "coverArt": 1, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "The Graveyard and the Ballroom", + "created": "2019-05-28T20:59:02.988372626+01:00" + }, + { + "id": 2, + "artistId": 1, + "artist": "A Certain Ratio", + "name": "To Each...", + "created": "2019-05-28T20:59:02.995320471+01:00" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_artist_id_three b/server/handler/test_data/test_get_artist_id_three new file mode 100644 index 0000000..24ad879 --- /dev/null +++ b/server/handler/test_data/test_get_artist_id_three @@ -0,0 +1,20 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "artist": { + "id": 3, + "name": "Anikas", + "album": [ + { + "id": 5, + "coverArt": 4, + "artistId": 3, + "artist": "Anikas", + "name": "Anika", + "created": "2019-05-28T20:59:03.035442597+01:00" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_artist_id_two b/server/handler/test_data/test_get_artist_id_two new file mode 100644 index 0000000..9ac78c4 --- /dev/null +++ b/server/handler/test_data/test_get_artist_id_two @@ -0,0 +1,28 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "artist": { + "id": 2, + "name": "13th Floor Elevators", + "album": [ + { + "id": 3, + "coverArt": 2, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "Easter Everywhere", + "created": "2019-05-28T20:59:03.010415595+01:00" + }, + { + "id": 4, + "coverArt": 3, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "The Psychedelic Sounds of the 13th Floor Elevators", + "created": "2019-05-28T20:59:03.022922683+01:00" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_artists_no_args b/server/handler/test_data/test_get_artists_no_args new file mode 100644 index 0000000..f851b26 --- /dev/null +++ b/server/handler/test_data/test_get_artists_no_args @@ -0,0 +1,32 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "artists": { + "index": [ + { + "name": "A", + "artist": [ + { + "id": 1, + "name": "A Certain Ratio" + }, + { + "id": 3, + "name": "Anikas" + } + ] + }, + { + "name": "#", + "artist": [ + { + "id": 2, + "name": "13th Floor Elevators" + } + ] + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_indexes_id_two b/server/handler/test_data/test_get_indexes_id_two new file mode 100644 index 0000000..8703106 --- /dev/null +++ b/server/handler/test_data/test_get_indexes_id_two @@ -0,0 +1,33 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "indexes": { + "lastModified": 0, + "index": [ + { + "name": "A", + "artist": [ + { + "id": 2, + "name": "A Certain Ratio" + }, + { + "id": 8, + "name": "Anika" + } + ] + }, + { + "name": "#", + "artist": [ + { + "id": 5, + "name": "13th Floor Lowervators" + } + ] + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_music_directory_with_tracks b/server/handler/test_data/test_get_music_directory_with_tracks new file mode 100644 index 0000000..d33ef8f --- /dev/null +++ b/server/handler/test_data/test_get_music_directory_with_tracks @@ -0,0 +1,223 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "directory": { + "id": 3, + "parent": 2, + "name": "(1994) The Graveyard and the Ballroom", + "child": [ + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 5, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/08.14 All Night Party.flac", + "size": 24960016, + "suffix": "flac", + "title": "All Night Party", + "track": 8, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 11, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/04.14 Choir.flac", + "size": 24728976, + "suffix": "flac", + "title": "Choir", + "track": 4, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 6, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/03.14 Crippled Child.flac", + "size": 21325811, + "suffix": "flac", + "title": "Crippled Child", + "track": 3, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 12, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/01.14 Do the Du (casse).flac", + "size": 20545509, + "suffix": "flac", + "title": "Do the Du (casse)", + "track": 1, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 8, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/02.14 Faceless.flac", + "size": 16657561, + "suffix": "flac", + "title": "Faceless", + "track": 2, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 1, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/13.14 Flight.flac", + "size": 37302417, + "suffix": "flac", + "title": "Flight", + "track": 13, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 2, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/05.14 Flight.flac", + "size": 24860635, + "suffix": "flac", + "title": "Flight", + "track": 5, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 3, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/14.14 Genotype_Phenotype.flac", + "size": 24349252, + "suffix": "flac", + "title": "Genotype/Phenotype", + "track": 14, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 13, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/06.14 I Feel.flac", + "size": 16118749, + "suffix": "flac", + "title": "I Feel", + "track": 6, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 4, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/09.14 Oceans.flac", + "size": 26401567, + "suffix": "flac", + "title": "Oceans", + "track": 9, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 14, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/07.14 Strain.flac", + "size": 17608752, + "suffix": "flac", + "title": "Strain", + "track": 7, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 7, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/12.14 Suspect.flac", + "size": 16592296, + "suffix": "flac", + "title": "Suspect", + "track": 12, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 10, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/10.14 The Choir.flac", + "size": 24106680, + "suffix": "flac", + "title": "The Choir", + "track": 10, + "type": "music" + }, + { + "album": "The Graveyard and the Ballroom", + "artist": "A Certain Ratio", + "contentType": "audio/x-flac", + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 9, + "parent": 3, + "path": "A Certain Ratio/(1994) The Graveyard and the Ballroom/11.14 The Fox.flac", + "size": 24054498, + "suffix": "flac", + "title": "The Fox", + "track": 11, + "type": "music" + } + ] + } + } +} diff --git a/server/handler/test_data/test_get_music_directory_without_tracks b/server/handler/test_data/test_get_music_directory_without_tracks new file mode 100644 index 0000000..04b8ccc --- /dev/null +++ b/server/handler/test_data/test_get_music_directory_without_tracks @@ -0,0 +1,28 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "directory": { + "id": 2, + "parent": 1, + "name": "A Certain Ratio", + "child": [ + { + "coverArt": 1, + "created": "0001-01-01T00:00:00Z", + "id": 3, + "isDir": true, + "parent": 2, + "title": "(1994) The Graveyard and the Ballroom" + }, + { + "created": "0001-01-01T00:00:00Z", + "isDir": true, + "id": 4, + "parent": 2, + "title": "(1981) To Each." + } + ] + } + } +} diff --git a/server/handler/test_data/test_search_three_q_13 b/server/handler/test_data/test_search_three_q_13 new file mode 100644 index 0000000..9689f82 --- /dev/null +++ b/server/handler/test_data/test_search_three_q_13 @@ -0,0 +1,24 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "searchResult3": { + "artist": [ + { + "id": 2, + "name": "13th Floor Elevators" + } + ], + "album": [ + { + "id": 4, + "coverArt": 3, + "artistId": 2, + "artist": "13th Floor Elevators", + "name": "The Psychedelic Sounds of the 13th Floor Elevators", + "created": "2019-05-28T20:59:03.022922683+01:00" + } + ] + } + } +} diff --git a/server/handler/test_data/test_search_three_q_ani b/server/handler/test_data/test_search_three_q_ani new file mode 100644 index 0000000..accc59d --- /dev/null +++ b/server/handler/test_data/test_search_three_q_ani @@ -0,0 +1,24 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "searchResult3": { + "artist": [ + { + "id": 3, + "name": "Anikas" + } + ], + "album": [ + { + "id": 5, + "coverArt": 4, + "artistId": 3, + "artist": "Anikas", + "name": "Anika", + "created": "2019-05-28T20:59:03.035442597+01:00" + } + ] + } + } +} diff --git a/server/handler/test_data/test_search_three_q_cert b/server/handler/test_data/test_search_three_q_cert new file mode 100644 index 0000000..2020872 --- /dev/null +++ b/server/handler/test_data/test_search_three_q_cert @@ -0,0 +1,14 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "searchResult3": { + "artist": [ + { + "id": 1, + "name": "A Certain Ratio" + } + ] + } + } +} diff --git a/server/handler/test_data/test_search_two_q_13 b/server/handler/test_data/test_search_two_q_13 new file mode 100644 index 0000000..5de3e60 --- /dev/null +++ b/server/handler/test_data/test_search_two_q_13 @@ -0,0 +1,25 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "searchResult2": { + "artist": [ + { + "id": 5, + "parent": 1, + "name": "13th Floor Lowervators" + } + ], + "album": [ + { + "coverArt": 3, + "created": "0001-01-01T00:00:00Z", + "id": 7, + "isDir": true, + "parent": 5, + "title": "(1966) The Psychedelic Sounds of the 13th Floor Elevators" + } + ] + } + } +} diff --git a/server/handler/test_data/test_search_two_q_ani b/server/handler/test_data/test_search_two_q_ani new file mode 100644 index 0000000..f7456bf --- /dev/null +++ b/server/handler/test_data/test_search_two_q_ani @@ -0,0 +1,25 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "searchResult2": { + "artist": [ + { + "id": 8, + "parent": 1, + "name": "Anika" + } + ], + "album": [ + { + "coverArt": 4, + "created": "0001-01-01T00:00:00Z", + "id": 11, + "isDir": true, + "parent": 10, + "title": "(2010) Anika" + } + ] + } + } +} diff --git a/server/handler/test_data/test_search_two_q_cert b/server/handler/test_data/test_search_two_q_cert new file mode 100644 index 0000000..c838b36 --- /dev/null +++ b/server/handler/test_data/test_search_two_q_cert @@ -0,0 +1,15 @@ +{ + "subsonic-response": { + "status": "ok", + "version": "1.9.0", + "searchResult2": { + "artist": [ + { + "id": 2, + "parent": 1, + "name": "A Certain Ratio" + } + ] + } + } +}