Skip to content

Commit 8d90aac

Browse files
committed
Test workaround for set.List() not maintaining order
1 parent fdb7dee commit 8d90aac

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cors_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net/http"
55
"net/http/httptest"
66
"regexp"
7+
"sort"
78
"strings"
89
"testing"
910

@@ -28,6 +29,15 @@ func assertHeaders(t *testing.T, resHeaders http.Header, expHeaders map[string]s
2829
for _, name := range allHeaders {
2930
got := strings.Join(resHeaders[name], ", ")
3031
want := expHeaders[name]
32+
if name == "Access-Control-Allow-Headers" || name == "Access-Control-Expose-Headers" {
33+
gSplit := strings.Split(got, ", ")
34+
sort.Strings(gSplit)
35+
got = strings.Join(gSplit, ", ")
36+
37+
wSplit := strings.Split(want, ", ")
38+
sort.Strings(wSplit)
39+
want = strings.Join(wSplit, ", ")
40+
}
3141
if got != want {
3242
t.Errorf("Response header %q = %q, want %q", name, got, want)
3343
}

0 commit comments

Comments
 (0)