Feat macos (#2)
--------- Co-authored-by: intelligence <intelligence@debian.local> Co-authored-by: jourintown <jourintown@proton.me> Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
1 parent
136bf7cfa3
commit
32e7f32e0a
22 files changed
+1360
-7
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import XCTest
|
||||
|
||||
@testable import Transui
|
||||
|
||||
final class TranscriptionClientTests: XCTestCase {
|
||||
func testAddsTranscriptionPath() {
|
||||
XCTAssertEqual(
|
||||
TranscriptionClient.endpointURL(from: "https://example.com/")?.absoluteString,
|
||||
"https://example.com/v1/audio/transcriptions"
|
||||
)
|
||||
}
|
||||
|
||||
func testKeepsFullTranscriptionPath() {
|
||||
XCTAssertEqual(
|
||||
TranscriptionClient.endpointURL(
|
||||
from: "https://example.com/v1/audio/transcriptions"
|
||||
)?.absoluteString,
|
||||
"https://example.com/v1/audio/transcriptions"
|
||||
)
|
||||
}
|
||||
|
||||
func testRejectsInvalidEndpoint() {
|
||||
XCTAssertNil(TranscriptionClient.endpointURL(from: ""))
|
||||
XCTAssertNil(TranscriptionClient.endpointURL(from: "example.com"))
|
||||
}
|
||||
|
||||
func testHostedFirstPlanFallsBackToLocal() {
|
||||
let plan = TranscriptionPlan(
|
||||
hosted: endpoint("Hosted", "https://hosted.example.com"),
|
||||
local: endpoint("Local", "http://localhost:8080"),
|
||||
hostedFirst: true
|
||||
)
|
||||
|
||||
XCTAssertEqual(plan.endpoints.map(\.label), ["Hosted", "Local"])
|
||||
}
|
||||
|
||||
func testDisabledHostedFirstUsesOnlyLocal() {
|
||||
let plan = TranscriptionPlan(
|
||||
hosted: endpoint("Hosted", "https://hosted.example.com"),
|
||||
local: endpoint("Local", "http://localhost:8080"),
|
||||
hostedFirst: false
|
||||
)
|
||||
|
||||
XCTAssertEqual(plan.endpoints.map(\.label), ["Local"])
|
||||
}
|
||||
|
||||
func testPlanSkipsEmptyEndpoints() {
|
||||
let plan = TranscriptionPlan(
|
||||
hosted: endpoint("Hosted", ""),
|
||||
local: endpoint("Local", ""),
|
||||
hostedFirst: true
|
||||
)
|
||||
|
||||
XCTAssertTrue(plan.endpoints.isEmpty)
|
||||
}
|
||||
|
||||
private func endpoint(_ label: String, _ value: String) -> TranscriptionEndpoint {
|
||||
TranscriptionEndpoint(label: label, endpoint: value, model: "", key: "")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user