Started off well
This commit is contained in:
36
Tests/MusicBrainzTests/QueryTests.swift
Normal file
36
Tests/MusicBrainzTests/QueryTests.swift
Normal file
@@ -0,0 +1,36 @@
|
||||
import Foundation
|
||||
import Testing
|
||||
|
||||
@testable import MusicBrainz
|
||||
|
||||
@Test func testArtistQueryBuilding() throws {
|
||||
let action: MusicBrainzSearchAction<Artist> = .artist(name: "Michael Jackson", gender: .male, country: .us)
|
||||
#expect(action.query.contains("artist:\"Michael Jackson\""))
|
||||
#expect(action.query.contains("gender:\"male\""))
|
||||
#expect(action.query.contains("country:\"US\""))
|
||||
}
|
||||
|
||||
@Test func testReleaseQueryBuilding() throws {
|
||||
let action: MusicBrainzSearchAction<Release> = .release(title: "Thriller", artist: "Michael Jackson", barcode: "07464381122")
|
||||
#expect(action.query.contains("release:\"Thriller\""))
|
||||
#expect(action.query.contains("artist:\"Michael Jackson\""))
|
||||
#expect(action.query.contains("barcode:\"07464381122\""))
|
||||
}
|
||||
|
||||
@Test func testRecordingQueryBuilding() throws {
|
||||
let action: MusicBrainzSearchAction<Recording> = .recording(title: "Billie Jean", isrc: "USSM18200385", video: true)
|
||||
#expect(action.query.contains("recording:\"Billie Jean\""))
|
||||
#expect(action.query.contains("isrc:\"USSM18200385\""))
|
||||
#expect(action.query.contains("video:\"true\""))
|
||||
}
|
||||
|
||||
@Test func testRawQueryBuilding() throws {
|
||||
let action: MusicBrainzSearchAction<Artist> = .artist(name: "Prince", raw: "type:person")
|
||||
#expect(action.query.contains("artist:\"Prince\""))
|
||||
#expect(action.query.contains("type:person"))
|
||||
}
|
||||
|
||||
@Test func testQueryEscaping() throws {
|
||||
let action: MusicBrainzSearchAction<Artist> = .artist(name: "Artist \"Quote\" Name")
|
||||
#expect(action.query == "artist:\"Artist \\\"Quote\\\" Name\"")
|
||||
}
|
||||
Reference in New Issue
Block a user