Skip to content
Myr

test(TOML): Add some tests for the TOML render (#3401)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by mstmdev · committed by GitHub · parent 297b664 · Browse files · 1 file+22 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+22 added−0 removed

  • other:+22 added−0 removed

1 file+22 added−0 removed

modified:render/render_test.go+22 added
6 unmodified lines
7import (8 "encoding/xml"9 "errors"10 "html/template"11 "net"12 "net/http"13 "net/http/httptest"14 "strconv"15 "strings"
238 unmodified lines
254 err := (YAML{&fail{}}).Render(w)255 assert.Error(t, err)256}257258func TestRenderTOML(t *testing.T) {259 w := httptest.NewRecorder()260 data := map[string]any{261 "foo": "bar",262 "html": "<b>",263 }264 (TOML{data}).WriteContentType(w)265 assert.Equal(t, "application/toml; charset=utf-8", w.Header().Get("Content-Type"))266267 err := (TOML{data}).Render(w)268 assert.NoError(t, err)269 assert.Equal(t, "foo = 'bar'\nhtml = '<b>'\n", w.Body.String())270 assert.Equal(t, "application/toml; charset=utf-8", w.Header().Get("Content-Type"))271}272273func TestRenderTOMLFail(t *testing.T) {274 w := httptest.NewRecorder()275 err := (TOML{net.IPv4bcast}).Render(w)276 assert.Error(t, err)277}278279// test Protobuf rendering280func TestRenderProtoBuf(t *testing.T) {281 w := httptest.NewRecorder()282 reps := []int64{int64(1), int64(2)}
252 unmodified lines