Skip to content

Commit 5a5733e

Browse files
committed
Fix get_usage method to handle mock auth key for testing
1 parent 5271a49 commit 5a5733e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/deepl/translator.cr

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,9 @@ module DeepL
453453
end
454454

455455
def get_usage : Usage
456-
if auth_key_is_free_account?
456+
if auth_key_is_mock? # FIXME: Workaround for testing
457+
get_usage_free
458+
elsif auth_key_is_free_account?
457459
get_usage_free
458460
else
459461
get_usage_pro
@@ -470,6 +472,10 @@ module DeepL
470472
auth_key.ends_with?(":fx")
471473
end
472474

475+
private def auth_key_is_mock? : Bool
476+
auth_key == "mock"
477+
end
478+
473479
def guess_target_language : String
474480
tl = ENV["DEEPL_TARGET_LANG"]?
475481
return tl if tl

0 commit comments

Comments
 (0)