Skip to content

Commit

Permalink
test: add test to verify bug
Browse files Browse the repository at this point in the history
Shows the problem mentioned in #186
  • Loading branch information
SgtPooki committed May 16, 2024
1 parent 41f88f8 commit 8a4233d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tooling/test/header_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package test

import (
"net/http"
"testing"

"github.com/stretchr/testify/assert"
)

func TestHeader(t *testing.T) {
// Manually create a response object with headers
resp := &http.Response{
Header: http.Header{
"Access-Control-Allow-Headers": []string{"Content-Type, Range, User-Agent, X-Requested-With"},
},
}

// Extract headers from the response
headers := resp.Header["Access-Control-Allow-Headers"]

// Test the HeaderBuilder function
hb := Header("Access-Control-Allow-Headers").Has("Content-Type", "Range", "User-Agent", "X-Requested-With")

checkOutput := hb.Check_.Check(headers)

// Check if the headers satisfy the conditions
assert.True(t, checkOutput.Success, checkOutput.Reason)
}

0 comments on commit 8a4233d

Please sign in to comment.