aboutsummaryrefslogtreecommitdiff
path: root/direct_client_test.go
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2020-03-30 23:15:47 +0700
committerShulhan <m.shulhan@gmail.com>2020-03-30 23:15:47 +0700
commit84fdfdb6ae4175a125fc67a6aed377476d31ee0e (patch)
tree28877c8088bb05b4d7bef8d6b585996128da68e4 /direct_client_test.go
parent7d2606dbcaaf3794907fbee185dcb1d78cfdb98c (diff)
downloadkamusku-84fdfdb6ae4175a125fc67a6aed377476d31ee0e.tar.xz
all: refactoring Client
The client will have two mode: direct or API. The direct mode connect to official KBBI website, request the word page, and parse the HTML to get the definition. The API mode connect to server API that provide caching of dictionary.
Diffstat (limited to 'direct_client_test.go')
-rw-r--r--direct_client_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/direct_client_test.go b/direct_client_test.go
new file mode 100644
index 0000000..894b876
--- /dev/null
+++ b/direct_client_test.go
@@ -0,0 +1,29 @@
+// Copyright 2020, Shulhan <m.shulhan@gmail.com>. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package kbbi
+
+import (
+ "io/ioutil"
+ "testing"
+)
+
+func TestDirectClient_parseHTMLKataDasar(t *testing.T) {
+ htmlBody, err := ioutil.ReadFile("testdata/kbbi_dasar.html")
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ cl, err := newDirectClient(nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ got, err := cl.parseHTMLKataDasar(htmlBody)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ t.Logf("Kata dasar: %v", got)
+}