Skip to content

Commit

Permalink
Allow other paths too. Thanks @RicoVZ
Browse files Browse the repository at this point in the history
  • Loading branch information
Evert-Arends authored and RicoVZ committed Aug 29, 2023
1 parent 65990a4 commit ffa9b5a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions go/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import (
"github.com/hatching/triage/types"
)

func (c *Client) SamplePath(ctx context.Context, sampleID, path string, resp interface{}) error {
path = "/v0/samples/" + sampleID + path
return c.jsonRequestJSON(ctx, http.MethodGet, path, nil, &resp)
}

func (c *Client) SampleSample(ctx context.Context, sampleID string) (io.ReadCloser, error) {
path := "/v0/samples/" + sampleID + "/sample"
return c.requestRawFile(ctx, http.MethodGet, path)
Expand Down
22 changes: 22 additions & 0 deletions go/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,25 @@ func TestArchiveZIP(t *testing.T) {
t.Fatal("Unexpected method")
}
}

func TestSamplePath(t *testing.T) {
ctx := context.Background()
m := ClientMock{}
m.Response = nil
m.StatusCode = 200
client := &Client{
httpClient: &m,
}
type test struct {
Name string
}
if err := client.SamplePath(ctx, "test-123", "/output.json", &test{}); err != nil {
t.Fatal(err)
}
if m.RequestUrl != "/v0/samples/test-123/output.json" {
t.Fatalf("Expected other request url %v", m.RequestUrl)
}
if m.RequestMethod != "GET" {
t.Fatal("Unexpected method")
}
}

0 comments on commit ffa9b5a

Please sign in to comment.