forked from tleyden/open-ocr
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ocr_rpc_client_test.go
61 lines (47 loc) · 1.44 KB
/
ocr_rpc_client_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
package ocrworker
import (
"testing"
"github.com/rs/zerolog/log"
"github.com/couchbaselabs/go.assert"
)
func init() {
}
func workerConfigForTests() WorkerConfig {
workerConfig := DefaultWorkerConfig()
return workerConfig
}
func rabbitConfigForTests() RabbitConfig {
rabbitConfig := DefaultTestConfig()
return rabbitConfig
}
// This test assumes that rabbit mq is running
func DisabledTestOcrRpcClientIntegration(t *testing.T) {
// TODO: serve this up through a fake webserver
// that reads from the filesystem
testImageUrl := "http://localhost:8080/img"
rabbitConfig := rabbitConfigForTests()
workerConfig := workerConfigForTests()
// requestID := "426d0ef9-a0c9-48cb-4562-f9d6f29a6ba5"
// kick off a worker
// this would normally happen on a different machine ..
ocrWorker, err := NewOcrRpcWorker(&workerConfig)
if err != nil {
log.Error().Str("component", "TEST").Err(err)
}
ocrWorker.Run()
ocrClient, err := NewOcrRpcClient(&rabbitConfig)
if err != nil {
log.Error().Str("component", "TEST").Err(err)
}
assert.True(t, err == nil)
for i := 0; i < 50; i++ {
ocrRequest := OcrRequest{ImgUrl: testImageUrl, EngineType: EngineMock}
decodeResult, _, err := ocrClient.DecodeImage(&ocrRequest)
if err != nil {
log.Error().Str("component", "TEST").Err(err)
}
assert.True(t, err == nil)
log.Info().Str("component", "TEST").Str("decodeResult", decodeResult.Text)
assert.Equals(t, decodeResult.Text, MockEngineResponse)
}
}