summaryrefslogtreecommitdiff
path: root/plugins/broadcast/websockets/access_validator_test.go
blob: 41372727a537e206b5c9cdcbc120be5dcba5c04c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package websockets

import (
	"testing"

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

func TestResponseWrapper_Body(t *testing.T) {
	w := newValidator()
	_, _ =w.Write([]byte("hello"))

	assert.Equal(t, []byte("hello"), w.Body())
}

func TestResponseWrapper_Header(t *testing.T) {
	w := newValidator()
	w.Header().Set("k", "value")

	assert.Equal(t, "value", w.Header().Get("k"))
}

func TestResponseWrapper_StatusCode(t *testing.T) {
	w := newValidator()
	w.WriteHeader(200)

	assert.True(t, w.IsOK())
}

func TestResponseWrapper_StatusCodeBad(t *testing.T) {
	w := newValidator()
	w.WriteHeader(400)

	assert.False(t, w.IsOK())
}