-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublish_test.go
56 lines (52 loc) · 1.22 KB
/
publish_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
54
55
56
package publisher
import (
"fmt"
"net/http"
"net/http/httptest"
"net/http/httputil"
"strings"
)
func ExamplePublish() {
changeset := &MetaChangeset{
Remote: "some-remote",
UnixTime: 1644410531,
OldShas: []string{"aaa"},
Sha: "bbb",
Changes: make([]Change, 0),
Loc: 9876,
Files: 31,
}
req, err := MakeRequest(changeset, "1CCC7924-051C-496E-8467-D494C1C37B2A", "https://host.com", "anyone", "secret")
if err != nil {
fmt.Println(err.Error())
return
}
res := httptest.NewRecorder()
ChangesetHandler := func(res http.ResponseWriter, req *http.Request) {
txt, err := httputil.DumpRequest(req, true)
if err != nil {
fmt.Println(err.Error())
return
}
dumpedReq := strings.ReplaceAll(string(txt), "\r\n", "\n")
fmt.Print(dumpedReq)
}
ChangesetHandler(res, req)
//Output:
// POST /api/organization/1CCC7924-051C-496E-8467-D494C1C37B2A/changeset HTTP/1.1
// Host: host.com
// Authorization: Basic YW55b25lOnNlY3JldA==
// Content-Type: application/vnd.smartbear.onereport.changeset.v1+json
//
// {
// "remote": "some-remote",
// "unixTime": 1644410531,
// "oldShas": [
// "aaa"
// ],
// "sha": "bbb",
// "changes": [],
// "loc": 9876,
// "files": 31
// }
}