Skip to content

Commit

Permalink
test(TOML): Add some tests for the TOML render (#3401)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstmdev committed Dec 22, 2022
1 parent 297b664 commit e868fd1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions render/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"encoding/xml"
"errors"
"html/template"
"net"
"net/http"
"net/http/httptest"
"strconv"
Expand Down Expand Up @@ -254,6 +255,27 @@ func TestRenderYAMLFail(t *testing.T) {
assert.Error(t, err)
}

func TestRenderTOML(t *testing.T) {
w := httptest.NewRecorder()
data := map[string]any{
"foo": "bar",
"html": "<b>",
}
(TOML{data}).WriteContentType(w)
assert.Equal(t, "application/toml; charset=utf-8", w.Header().Get("Content-Type"))

err := (TOML{data}).Render(w)
assert.NoError(t, err)
assert.Equal(t, "foo = 'bar'\nhtml = '<b>'\n", w.Body.String())
assert.Equal(t, "application/toml; charset=utf-8", w.Header().Get("Content-Type"))
}

func TestRenderTOMLFail(t *testing.T) {
w := httptest.NewRecorder()
err := (TOML{net.IPv4bcast}).Render(w)
assert.Error(t, err)
}

// test Protobuf rendering
func TestRenderProtoBuf(t *testing.T) {
w := httptest.NewRecorder()
Expand Down

0 comments on commit e868fd1

Please sign in to comment.