From e007c69625ebfb760ecc873730786522bdc8a997 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 5 Mar 2024 17:46:52 +0000 Subject: [PATCH] test and fix file upload! --- main.go | 6 ++---- rageshake.sample.yaml | 6 ++---- submit_test.go | 8 ++++++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index f59ace9..f9e01a6 100644 --- a/main.go +++ b/main.go @@ -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.") diff --git a/rageshake.sample.yaml b/rageshake.sample.yaml index 8072fa1..35be478 100644 --- a/rageshake.sample.yaml +++ b/rageshake.sample.yaml @@ -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 diff --git a/submit_test.go b/submit_test.go index f3af92b..159cd32 100644 --- a/submit_test.go +++ b/submit_test.go @@ -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, @@ -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) } @@ -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) }