-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathhttpresponseformat_test.go
35 lines (31 loc) · 1.13 KB
/
httpresponseformat_test.go
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
// httpresponseformat_test.go
// ~~~~~~~~~
// This module implements the HttpResponseFormat tests.
// :authors: Konstantin Bokarius.
// :copyright: (c) 2015 by Fanout, Inc.
// :license: MIT, see LICENSE for more details.
package gripcontrol
import (
"encoding/base64"
"github.com/stretchr/testify/assert"
"testing"
)
func TestHttpResponseFormatName(t *testing.T) {
fmt := &HttpResponseFormat{}
assert.Equal(t, fmt.Name(), "http-response")
}
func TestHttpResponseFormatExport(t *testing.T) {
fmt := &HttpResponseFormat{}
assert.Equal(t, fmt.Export(), map[string]interface{}{})
fmt = &HttpResponseFormat{Code: 1, Reason: "reason",
Headers: map[string]string{"header": "hval"},
Body: []byte("body")}
assert.Equal(t, fmt.Export(), map[string]interface{}{
"code": 1, "reason": "reason",
"headers": map[string]string{"header": "hval"},
"body": "body"})
fmt = &HttpResponseFormat{Headers: map[string]string{},
Body: []byte("\xbd\xb2\x3d\xbc\x20\xe2\x8c\xFF")}
assert.Equal(t, fmt.Export(), map[string]interface{}{"body-bin": base64.StdEncoding.EncodeToString(
[]byte("\xbd\xb2\x3d\xbc\x20\xe2\x8c\xFF"))})
}