forked from rtt/Go-Solr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solr_test.go
53 lines (41 loc) · 904 Bytes
/
solr_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
package solr
import (
"testing"
)
func TestInitOK(t *testing.T) {
c, _ := Init("localhost", 8696, "core0")
if c.URL != "http://localhost:8696/solr/core0" {
t.Fail()
}
}
func TestInitInvalidHost(t *testing.T) {
_, err := Init("", 700000, "core0")
if err == nil {
t.Fail()
}
}
func TestInitInvalidPort(t *testing.T) {
_, err := Init("localhost", 700000, "core0")
if err == nil {
t.Fail()
}
}
func TestSolrSelectString(t *testing.T) {
c, _ := Init("localhost", 8696, "core0")
q := &Query{
Params: URLParamMap{
"q": []string{"id:1"},
},
}
s := SolrSelectString(c, q.String(), "select")
if s != "http://localhost:8696/solr/core0/select?wt=json&q=id%3A1" {
t.Fail()
}
}
func TestSolrUpdateString(t *testing.T) {
c, _ := Init("localhost", 8696, "core0")
s := SolrUpdateString(c, true)
if s != "http://localhost:8696/solr/core0/update?commit=true" {
t.Fail()
}
}