MCPcopy
hub / github.com/rclone/rclone / TestErrorHandler

Function TestErrorHandler

backend/sugarsync/sugarsync_internal_test.go:12–59  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestErrorHandler(t *testing.T) {
13 for _, test := range []struct {
14 name string
15 body string
16 code int
17 status string
18 want string
19 }{
20 {
21 name: "empty",
22 body: "",
23 code: 500,
24 status: "internal error",
25 want: `HTTP error 500 (internal error) returned body: ""`,
26 },
27 {
28 name: "unknown",
29 body: "<h1>unknown</h1>",
30 code: 500,
31 status: "internal error",
32 want: `HTTP error 500 (internal error) returned body: "<h1>unknown</h1>"`,
33 },
34 {
35 name: "blank",
36 body: "Nothing here <h3></h3>",
37 code: 500,
38 status: "internal error",
39 want: `HTTP error 500 (internal error) returned body: "Nothing here <h3></h3>"`,
40 },
41 {
42 name: "real",
43 body: "<h1>an error</h1>\n<h3>Can not move sync folder.</h3>\n<p>more stuff</p>",
44 code: 500,
45 status: "internal error",
46 want: `HTTP error 500 (internal error): Can not move sync folder.`,
47 },
48 } {
49 t.Run(test.name, func(t *testing.T) {
50 resp := http.Response{
51 Body: io.NopCloser(bytes.NewBufferString(test.body)),
52 StatusCode: test.code,
53 Status: test.status,
54 }
55 got := errorHandler(&resp)
56 assert.Equal(t, test.want, got.Error())
57 })
58 }
59}

Callers

nothing calls this directly

Calls 4

errorHandlerFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…