-
Notifications
You must be signed in to change notification settings - Fork 19
/
svc_translationprovider_test.go
116 lines (103 loc) · 3.15 KB
/
svc_translationprovider_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package lokalise
import (
"fmt"
"net/http"
"reflect"
"testing"
)
func TestTranslationProviderService_List(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc(
fmt.Sprintf("/teams/%d/translation_providers", 444),
func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
testMethod(t, r, "GET")
testHeader(t, r, apiTokenHeader, testApiToken)
_, _ = fmt.Fprint(w, `{
"translation_providers": [
{
"provider_id": 1
}
]
}`)
})
r, err := client.TranslationProviders().List(444)
if err != nil {
t.Errorf("TranslationProviders.List returned error: %v", err)
}
want := []TranslationProvider{
{
ProviderID: 1,
},
}
if !reflect.DeepEqual(r.TranslationProviders, want) {
t.Errorf("TranslationProviders.List returned %+v, want %+v", r.TranslationProviders, want)
}
}
func TestTranslationProviderService_Retrieve(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()
mux.HandleFunc(
fmt.Sprintf("/teams/%d/translation_providers/%d", 444, 1),
func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
testMethod(t, r, "GET")
testHeader(t, r, apiTokenHeader, testApiToken)
_, _ = fmt.Fprint(w, `{
"provider_id": 1,
"name": "Gengo",
"slug": "gengo",
"price_pair_min": "0.00",
"website_url": "https://gengo.com",
"description": "At Gengo, our mission is to provide language services to everyone and connect a global community. Our network of over 18,000 translators are tested and qualified to meet stringent project standards. Translators are based around the world and in every timezone, which enables us to support over 35 languages and work towards the Gengo mission.",
"tiers": [
{
"tier_id": 1,
"title": "Native speaker"
}
],
"pairs": [
{
"tier_id": 1,
"from_lang_iso": "en_US",
"from_lang_name": "English (United States)",
"to_lang_iso": "ru",
"to_lang_name": "Russian",
"price_per_word": "0.07"
}
]
}`)
})
r, err := client.TranslationProviders().Retrieve(444, 1)
if err != nil {
t.Errorf("TranslationProviders.Retrieve returned error: %v", err)
}
want := TranslationProvider{
ProviderID: 1,
Name: "Gengo",
Slug: "gengo",
PricePairMin: "0.00",
WebsiteURL: "https://gengo.com",
Description: "At Gengo, our mission is to provide language services to everyone and connect a global community. Our network of over 18,000 translators are tested and qualified to meet stringent project standards. Translators are based around the world and in every timezone, which enables us to support over 35 languages and work towards the Gengo mission.",
Tiers: []TranslationTier{
{
TierID: 1,
Title: "Native speaker",
},
},
Pairs: []TranslationPair{
{
TierID: 1,
FromLangISO: "en_US",
FromLangName: "English (United States)",
ToLangISO: "ru",
ToLangName: "Russian",
PricePerWord: "0.07",
},
},
}
if !reflect.DeepEqual(r, want) {
t.Errorf("TranslationProviders.Retrieve returned %+v, want %+v", r, want)
}
}