forked from mattn/go-redmine
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclient_test.go
42 lines (40 loc) · 1.66 KB
/
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
package redmine
import (
"github.com/stretchr/testify/require"
"testing"
)
func TestClient_concatParameters(t *testing.T) {
type args struct {
requestParameters []string
}
tests := []struct {
name string
args args
want string
}{
{"should return empty string for zero parameters", args{}, ""},
{"should return same string for one parameters", args{[]string{"key=value"}}, "key=value"},
{"should return &-delimited string for two parameters", args{[]string{"key=value", "hello=world"}},
"key=value&hello=world"},
{"should remove empty parameter at the start and return two parameters", args{[]string{"", "key=value", "hello=world"}},
"key=value&hello=world"},
{"should remove empty parameter in the middle and return two parameters", args{[]string{"key=value", "", "hello=world"}},
"key=value&hello=world"},
{"should remove empty parameter in the end and return two parameters", args{[]string{"key=value", "hello=world", ""}},
"key=value&hello=world"},
{"should remove multiple empty parameter at the start and return two parameters", args{[]string{"", "", "key=value", "hello=world"}},
"key=value&hello=world"},
{"should remove multiple empty parameter in the middle and return two parameters", args{[]string{"key=value", "", "", "hello=world"}},
"key=value&hello=world"},
{"should remove multiple empty parameter in the end and return two parameters", args{[]string{"key=value", "hello=world", "", ""}},
"key=value&hello=world"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
c := &Client{}
if got := c.concatParameters(tt.args.requestParameters...); got != tt.want {
require.Equal(t, tt.want, got)
}
})
}
}