Skip to content

Commit

Permalink
Add translation test case for DeepL::Translator
Browse files Browse the repository at this point in the history
  • Loading branch information
kojix2 committed Jan 30, 2025
1 parent 475a8ed commit af73494
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test_with_deepl_mock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ jobs:
run: shards install --without-development

- name: Run tests
run: crystal spec -Ddeepl_mock
run: |
echo $DEEPL_AUTH_KEY
crystal spec -Ddeepl_mock
env:
DEEPL_SERVER_URL: http://localhost:3000
HTTP_PROXY: http://localhost:3001
DEEPL_AUTH_KEY: mock
4 changes: 2 additions & 2 deletions spec/spec_helper.cr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec"
{% if flag?(:deepl_mock) %}
STDERR.puts " Using mock for DeepL API ".colorize.back(:magenta)
require "./crest_extension_for_mock"
STDERR.puts " Using mock for DeepL API ".colorize.back(:magenta)
require "./crest_extension_for_mock"
{% end %}
require "../src/deepl"
7 changes: 7 additions & 0 deletions spec/translator_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,11 @@ describe DeepL::Translator do
output_file.parent.should eq(Path[__DIR__] / "fixtures")
output_file.basename.to_s.should match(/sample_PT-BR_\d{10}.txt/)
end

{% if flag?(:deepl_mock) %}
it "can translate text using mock" do
t = DeepL::Translator.new
t.translate_text("proton beam", "DE", "EN").should eq("Protonenstrahl")
end
{% end %}
end

0 comments on commit af73494

Please sign in to comment.