mirror of https://github.com/databricks/cli.git
Serialize all header values in acceptance tests (#2311)
## Changes Based on feedback in https://github.com/databricks/cli/pull/2296#discussion_r1946660650. Previously we only serialized the first value for a header in the requests log. Now we serialise all values for a header key. ## Tests Existing test
This commit is contained in:
parent
4ebc86282f
commit
ee440e65fe
|
@ -1 +1 @@
|
|||
{"headers":{"Authorization":"Bearer [DATABRICKS_TOKEN]","User-Agent":"cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/jobs_create cmd-exec-id/[UUID] auth/pat"},"method":"POST","path":"/api/2.1/jobs/create","body":{"name":"abc"}}
|
||||
{"headers":{"Authorization":["Bearer [DATABRICKS_TOKEN]"],"User-Agent":["cli/[DEV_VERSION] databricks-sdk-go/[SDK_VERSION] go/[GO_VERSION] os/[OS] cmd/jobs_create cmd-exec-id/[UUID] auth/pat"]},"method":"POST","path":"/api/2.1/jobs/create","body":{"name":"abc"}}
|
||||
|
|
|
@ -31,10 +31,10 @@ type Server struct {
|
|||
}
|
||||
|
||||
type Request struct {
|
||||
Headers map[string]string `json:"headers,omitempty"`
|
||||
Method string `json:"method"`
|
||||
Path string `json:"path"`
|
||||
Body any `json:"body"`
|
||||
Headers http.Header `json:"headers,omitempty"`
|
||||
Method string `json:"method"`
|
||||
Path string `json:"path"`
|
||||
Body any `json:"body"`
|
||||
}
|
||||
|
||||
func New(t testutil.TestingT) *Server {
|
||||
|
@ -109,12 +109,14 @@ func (s *Server) Handle(pattern string, handler HandlerFunc) {
|
|||
body, err := io.ReadAll(r.Body)
|
||||
assert.NoError(s.t, err)
|
||||
|
||||
headers := make(map[string]string)
|
||||
headers := make(http.Header)
|
||||
for k, v := range r.Header {
|
||||
if len(v) == 0 || !slices.Contains(s.IncludeRequestHeaders, k) {
|
||||
if !slices.Contains(s.IncludeRequestHeaders, k) {
|
||||
continue
|
||||
}
|
||||
headers[k] = v[0]
|
||||
for _, vv := range v {
|
||||
headers.Add(k, vv)
|
||||
}
|
||||
}
|
||||
|
||||
s.Requests = append(s.Requests, Request{
|
||||
|
|
Loading…
Reference in New Issue