forked from paulmach/osm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
changeset_test.go
46 lines (39 loc) · 984 Bytes
/
changeset_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
package osmapi
import (
"context"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
func TestChangeset_urls(t *testing.T) {
ctx := context.Background()
url := ""
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
url = r.URL.String()
w.Write([]byte(`<osm></osm>`))
}))
defer ts.Close()
DefaultDatasource.BaseURL = ts.URL
defer func() {
DefaultDatasource.BaseURL = BaseURL
}()
t.Run("changeset", func(t *testing.T) {
Changeset(ctx, 1)
if !strings.Contains(url, "changeset/1") {
t.Errorf("incorrect path: %v", url)
}
})
t.Run("changeset with discussion", func(t *testing.T) {
ChangesetWithDiscussion(ctx, 1)
if !strings.Contains(url, "changeset/1?include_discussion=true") {
t.Errorf("incorrect path: %v", url)
}
})
t.Run("changeset download", func(t *testing.T) {
ChangesetDownload(ctx, 1)
if !strings.Contains(url, "changeset/1/download") {
t.Errorf("incorrect path: %v", url)
}
})
}