Skip to content

Commit

Permalink
test and fix file upload!
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Mar 5, 2024
1 parent 3094b5d commit e007c69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 2 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ const DefaultIssueBodyTemplate = `User message:
{{ $key }}: ` + "`{{ $val }}`" + `
{{ end }}
[Logs]({{ .ListingURL }}) ([archive]({{ .ListingURL }}?format=tar.gz))
{{ range $file := .Files -}}
/ [{{ . }}]({{ .ListingURL }}/{{ . }})"
{{ end }}
{{- range $file := .Files}} / [{{ $file }}]({{ $.ListingURL }}/{{ $file }})
{{- end }}
`

var configPath = flag.String("config", "rageshake.yaml", "The path to the config file. For more information, see the config file in this repository.")
Expand Down
6 changes: 2 additions & 4 deletions rageshake.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ issue_body_template: |
{{ $key }}: `{{ $val }}`
{{ end }}
[Logs]({{ .ListingURL }}) ([archive]({{ .ListingURL }}?format=tar.gz))
{{ range $file := .Files -}}
/ [{{ . }}]({{ .ListingURL }}/{{ . }})"
{{ end }}
{{- range $file := .Files}} / [{{ $file }}]({{ $.ListingURL }}/{{ $file }})
{{- end }}
# a GitLab personal access token (https://gitlab.com/-/profile/personal_access_tokens), which
# will be used to create a GitLab issue for each report. It requires
Expand Down
8 changes: 6 additions & 2 deletions submit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,10 @@ id
Content-Disposition: form-data; name="version"
1
------WebKitFormBoundarySsdgl8Nq9voFyhdO
Content-Disposition: form-data; name="file"; filename="etc/passwd.txt"
file
------WebKitFormBoundarySsdgl8Nq9voFyhdO--
`
p, _ := testParsePayload(t, body,
Expand All @@ -453,7 +457,7 @@ Content-Disposition: form-data; name="version"
if *issueReq.Title != "test words." {
t.Errorf("Title: got %s, want %s", *issueReq.Title, "test words.")
}
expectedBody := "User message:\n\ntest words.\n\nUser-Agent: `xxx`\nVersion: `1`\ndevice_id: `id`\nuser_id: `id`\n\n[Logs](http://test/listing/foo) ([archive](http://test/listing/foo?format=tar.gz))\n\n\n"
expectedBody := "User message:\n\ntest words.\n\nUser-Agent: `xxx`\nVersion: `1`\ndevice_id: `id`\nuser_id: `id`\n\n[Logs](http://test/listing/foo) ([archive](http://test/listing/foo?format=tar.gz)) / [passwd.txt](http://test/listing/foo/passwd.txt)\n"
if *issueReq.Body != expectedBody {
t.Errorf("Body: got %s, want %s", *issueReq.Body, expectedBody)
}
Expand Down Expand Up @@ -489,7 +493,7 @@ riot-web
if *issueReq.Title != "test words." {
t.Errorf("Title: got %s, want %s", *issueReq.Title, "test words.")
}
expectedBody := "User message:\n\n\ntest words.\n"
expectedBody := "User message:\n\ntest words.\n"
if !strings.HasPrefix(*issueReq.Body, expectedBody) {
t.Errorf("Body: got %s, want %s", *issueReq.Body, expectedBody)
}
Expand Down

0 comments on commit e007c69

Please sign in to comment.