Skip to content

Commit 9240904

Browse files
committed
Merge pull request #35 from djinn/master
Made appropriate change for fixing variable error report
2 parents 9913b4b + f289ea8 commit 9240904

File tree

2 files changed

+77
-78
lines changed

2 files changed

+77
-78
lines changed

solr/connection_test.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package solr
22

33
import (
4-
"testing"
54
"fmt"
65
"net/url"
7-
)
6+
"strings"
7+
"testing"
8+
)
89

910
func TestConnection(t *testing.T) {
1011
_, err1 := NewConnection("fakedomain.tld", "core0")
@@ -26,22 +27,23 @@ func TestConnection(t *testing.T) {
2627
func TestConnectionResourceInvalidDomain(t *testing.T) {
2728
conn, err := NewConnection("http://www.fakedomain.tld/", "core0")
2829
_, err = conn.Resource("select", &url.Values{})
29-
expected := "Get http://www.fakedomain.tld/core0/select?wt=json: dial tcp: lookup www.fakedomain.tld: no such host"
30-
if err.Error() != expected {
30+
expected := "Get http://www.fakedomain.tld/core0/select?wt=json: dial tcp"
31+
error_report := err.Error()
32+
if strings.HasPrefix(error_report, expected) == false {
3133
t.Errorf("expected '%s' but got '%s'", expected, err.Error())
3234
}
3335
}
3436

3537
func TestConnectionUpdateInvalidDomain(t *testing.T) {
3638
conn, err := NewConnection("http://www.fakedomain.tld/", "core0")
3739
_, err = conn.Update(map[string]interface{}{}, nil)
38-
expected := "Post http://www.fakedomain.tld/core0/update/?wt=json: dial tcp: lookup www.fakedomain.tld: no such host"
39-
if err.Error() != expected {
40+
expected := "Post http://www.fakedomain.tld/core0/update/?wt=json: dial tcp"
41+
error_report := err.Error()
42+
if strings.HasPrefix(error_report, expected) == false {
4043
t.Errorf("expected '%s' but got '%s'", expected, err.Error())
4144
}
4245
}
4346

44-
4547
func TestBytes2JsonWrongJson(t *testing.T) {
4648
data := []byte(`<xml><x>y</x><yy>boo</yy></xml>`)
4749
d, err := bytes2json(&data)
@@ -63,7 +65,7 @@ func TestBytes2Json(t *testing.T) {
6365
if d["two"].(float64) != 2 {
6466
t.Errorf("two should have 2 as value")
6567
}
66-
68+
6769
}
6870

6971
func PrintMapInterface(d map[string]interface{}) {
@@ -171,16 +173,16 @@ func TestSuccessStatus(t *testing.T) {
171173
if successStatus(data) != false {
172174
t.Errorf("Status check should give false but got true")
173175
}
174-
176+
175177
data2 := map[string]interface{}{
176178
"error": map[string]interface{}{
177179
"msg": "Must specify a Content-Type header with POST requests",
178180
"code": float64(415)}}
179-
181+
180182
if successStatus(data2) != false {
181183
t.Errorf("Status check should give false but got true")
182184
}
183-
185+
184186
data3 := map[string]interface{}{
185187
"responseHeader": map[string]interface{}{
186188
"status": float64(0),
@@ -200,4 +202,4 @@ func TestSuccessStatus(t *testing.T) {
200202
if successStatus(data3) != true {
201203
t.Errorf("Status check should give true but got false")
202204
}
203-
}
205+
}

0 commit comments

Comments
 (0)