chore: upgrade Go to 1.27 (#30601)
This commit is contained in:
parent
748d36d130
commit
e63bae0c8b
37 changed files with 135 additions and 154 deletions
|
|
@ -23,10 +23,10 @@ func newTestConnection(baseURL string) *Connection {
|
|||
|
||||
// newStateConnection returns a connection serving state for any entity
|
||||
func newStateConnection(t *testing.T, state string) *Connection {
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
srv := httptest.NewTestServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Fprintf(w, `{"entity_id":"sensor.foo","state":%q}`, state)
|
||||
}))
|
||||
t.Cleanup(srv.Close)
|
||||
srv.Start()
|
||||
|
||||
return newTestConnection(srv.URL)
|
||||
}
|
||||
|
|
@ -116,13 +116,13 @@ func TestCallSwitchService_DomainDispatch(t *testing.T) {
|
|||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var gotPath, gotBody string
|
||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
srv := httptest.NewTestServer(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
gotPath = r.URL.Path
|
||||
body, _ := io.ReadAll(r.Body)
|
||||
gotBody = string(body)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
}))
|
||||
defer srv.Close()
|
||||
srv.Start()
|
||||
|
||||
err := newTestConnection(srv.URL).CallSwitchService(tc.entity, tc.turnOn)
|
||||
|
||||
|
|
|
|||
|
|
@ -4,19 +4,9 @@ package urlvalues
|
|||
import (
|
||||
"errors"
|
||||
"net/url"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Copy creates a deep copy of url values
|
||||
func Copy(q url.Values) url.Values {
|
||||
res := make(url.Values, len(q))
|
||||
for k, v := range q {
|
||||
res[k] = slices.Clone(v)
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// Require verifies that url contains the required non-nil values
|
||||
func Require(q url.Values, keys ...string) error {
|
||||
for _, k := range keys {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue