aboutsummaryrefslogtreecommitdiff
path: root/api_client_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-01-31 04:56:36 +0700
committerShulhan <ms@kilabit.info>2021-01-31 06:16:54 +0700
commit6c7bfd42bc1128f5969e9e40b23d6b828601f7cb (patch)
tree8138149fde47f135b965be0837b4f8b83421728f /api_client_test.go
parent734ce643ecbc992834a8f78b44904b82b09bc84b (diff)
downloadkamusku-6c7bfd42bc1128f5969e9e40b23d6b828601f7cb.tar.xz
all: rewrite the server
This commit move the directClient to different repository called kamusku and changes the module name from kamusku to kamusd.
Diffstat (limited to 'api_client_test.go')
-rw-r--r--api_client_test.go39
1 files changed, 20 insertions, 19 deletions
diff --git a/api_client_test.go b/api_client_test.go
index a7b408a..46dac0c 100644
--- a/api_client_test.go
+++ b/api_client_test.go
@@ -1,16 +1,17 @@
-// Copyright 2020, Shulhan <m.shulhan@gmail.com>. All rights reserved.
+// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package kamusku
+package kamusd
import (
"testing"
+ "git.sr.ht/~shulhan/kamusku"
"github.com/shuLhan/share/lib/test"
)
-func TestApiClient_CariDefinisi_offline(t *testing.T) {
+func TestApiClient_Lookup_offline(t *testing.T) {
testServer.offline = true
client := newAPIClient(testServerAPI)
@@ -18,7 +19,7 @@ func TestApiClient_CariDefinisi_offline(t *testing.T) {
cases := []struct {
desc string
words []string
- exp DefinisiResponse
+ exp kamusku.LookupResponse
expError string
}{{
desc: "With empty input",
@@ -28,13 +29,13 @@ func TestApiClient_CariDefinisi_offline(t *testing.T) {
}, {
desc: "With valid word in cache",
words: []string{"mengeja"},
- exp: DefinisiResponse{
+ exp: kamusku.LookupResponse{
"mengeja": testKataMengeja,
},
}, {
desc: "With duplicate words",
words: []string{"mengeja", "mengeja"},
- exp: DefinisiResponse{
+ exp: kamusku.LookupResponse{
"mengeja": testKataMengeja,
},
}}
@@ -42,17 +43,17 @@ func TestApiClient_CariDefinisi_offline(t *testing.T) {
for _, c := range cases {
t.Logf(c.desc)
- got, err := client.CariDefinisi(c.words)
+ got, err := client.Lookup(c.words)
if err != nil {
test.Assert(t, "error", c.expError, err.Error(), true)
continue
}
- test.Assert(t, "DefinisiResponse", c.exp, got, true)
+ test.Assert(t, "kamusku.LookupResponse", c.exp, got, true)
}
}
-func TestApiClient_CariDefinisi_online(t *testing.T) {
+func TestApiClient_Lookup_online(t *testing.T) {
t.Skip()
testServer.offline = false
@@ -62,31 +63,31 @@ func TestApiClient_CariDefinisi_online(t *testing.T) {
cases := []struct {
desc string
words []string
- exp DefinisiResponse
+ exp kamusku.LookupResponse
expError string
}{{
desc: "With empty input",
}, {
desc: "With valid word in cache",
words: []string{"mengeja"},
- exp: DefinisiResponse{
+ exp: kamusku.LookupResponse{
"mengeja": testKataMengeja,
},
}, {
desc: "With duplicate words",
words: []string{"mengeja", "mengeja"},
- exp: DefinisiResponse{
+ exp: kamusku.LookupResponse{
"mengeja": testKataMengeja,
},
}, {
desc: "With one of the word not in cache",
words: []string{"mengeja", "eja"},
- exp: DefinisiResponse{
+ exp: kamusku.LookupResponse{
"mengeja": testKataMengeja,
- "eja": &Kata{
- Definisi: []*DefinisiKata{{
- Isi: "lafal huruf satu demi satu",
- Kelas: []string{"Verba: kata kerja"},
+ "eja": &kamusku.Word{
+ Definition: []*kamusku.WordDefinition{{
+ Value: "lafal huruf satu demi satu",
+ Classes: []string{"Verba: kata kerja"},
}},
},
},
@@ -95,7 +96,7 @@ func TestApiClient_CariDefinisi_online(t *testing.T) {
for _, c := range cases {
t.Logf(c.desc)
- got, err := client.CariDefinisi(c.words)
+ got, err := client.Lookup(c.words)
if err != nil {
test.Assert(t, "error", c.expError, err.Error(), true)
continue
@@ -105,6 +106,6 @@ func TestApiClient_CariDefinisi_online(t *testing.T) {
t.Logf("got: %s = %+v", k, v)
}
- test.Assert(t, "DefinisiResponse", c.exp, got, true)
+ test.Assert(t, "LookupResponse", c.exp, got, true)
}
}