From ca5ce6ac22d8e44f2be26c4182366c588d36a32e Mon Sep 17 00:00:00 2001 From: fabiante Date: Sun, 24 Sep 2023 12:45:05 +0200 Subject: [PATCH] Add Context usage to HTTPDriver --- tests/driver/http.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/driver/http.go b/tests/driver/http.go index cb27c3a..3c8b3ec 100644 --- a/tests/driver/http.go +++ b/tests/driver/http.go @@ -2,6 +2,7 @@ package driver import ( "bytes" + "context" "encoding/json" "fmt" "io" @@ -44,7 +45,7 @@ func (driver *HTTPDriver) newRequest(method, url string, body io.Reader) (*http. return req, nil } -func (driver *HTTPDriver) ResolvePURL(domain string, name string) (*url.URL, error) { +func (driver *HTTPDriver) ResolvePURL(ctx context.Context, domain string, name string) (*url.URL, error) { req, err := driver.newRequest(http.MethodGet, fmt.Sprintf("%s/r/%s/%s", driver.BasePath, domain, name), nil) if err != nil { return nil, err @@ -72,7 +73,7 @@ func (driver *HTTPDriver) ResolvePURL(domain string, name string) (*url.URL, err return loc, nil } -func (driver *HTTPDriver) SavePURL(purl *dsl.PURL) (string, error) { +func (driver *HTTPDriver) SavePURL(ctx context.Context, purl *dsl.PURL) (string, error) { body := bytes.NewBuffer([]byte{}) err := json.NewEncoder(body).Encode(map[string]string{ "target": purl.Target.String(), @@ -107,7 +108,7 @@ func (driver *HTTPDriver) SavePURL(purl *dsl.PURL) (string, error) { return r.Path, nil } -func (driver *HTTPDriver) CreateDomain(name string) error { +func (driver *HTTPDriver) CreateDomain(ctx context.Context, name string) error { req, err := driver.newRequest(http.MethodPost, fmt.Sprintf("%s/a/domains/%s", driver.BasePath, name), nil) if err != nil { return err