-
Notifications
You must be signed in to change notification settings - Fork 5
/
config_test.go
49 lines (44 loc) · 1017 Bytes
/
config_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
package gnparser_test
import (
"runtime"
"testing"
"github.com/gnames/gnfmt"
"github.com/gnames/gnparser"
"github.com/stretchr/testify/assert"
)
func TestNew(t *testing.T) {
cfg := gnparser.NewConfig()
deflt := gnparser.Config{
Format: gnfmt.CSV,
JobsNum: runtime.NumCPU(),
BatchSize: 50_000,
IgnoreHTMLTags: false,
WithDetails: false,
Port: 8080,
IsTest: false,
}
assert.Equal(t, deflt, cfg)
}
func TestNewOpts(t *testing.T) {
opts := opts()
cnf := gnparser.NewConfig(opts...)
updt := gnparser.Config{
Format: gnfmt.CompactJSON,
JobsNum: 161,
BatchSize: 1,
IgnoreHTMLTags: true,
WithDetails: true,
Port: 8989,
}
assert.Equal(t, updt, cnf)
}
func opts() []gnparser.Option {
return []gnparser.Option{
gnparser.OptFormat(gnfmt.CompactJSON),
gnparser.OptJobsNum(161),
gnparser.OptBatchSize(1),
gnparser.OptIgnoreHTMLTags(true),
gnparser.OptWithDetails(true),
gnparser.OptPort(8989),
}
}