diff --git a/binding/binding_test.go b/binding/binding_test.go index a9f8b9e3..cdf1c23c 100644 --- a/binding/binding_test.go +++ b/binding/binding_test.go @@ -1403,6 +1403,23 @@ func TestPlainBinding(t *testing.T) { require.NoError(t, p.Bind(req, ptr)) } +func TestPlainBindingBindBody(t *testing.T) { + p := Plain + + var s string + require.NoError(t, p.BindBody([]byte("test body"), &s)) + assert.Equal(t, "test body", s) + + var bs []byte + require.NoError(t, p.BindBody([]byte("test bytes"), &bs)) + assert.Equal(t, []byte("test bytes"), bs) + + var i int + require.Error(t, p.BindBody([]byte("test"), &i)) + + require.NoError(t, p.BindBody([]byte("test"), nil)) +} + func testProtoBodyBindingFail(t *testing.T, b Binding, name, path, badPath, body, badBody string) { assert.Equal(t, name, b.Name()) diff --git a/ginS/gins_test.go b/ginS/gins_test.go index ffde85d2..1821e780 100644 --- a/ginS/gins_test.go +++ b/ginS/gins_test.go @@ -244,3 +244,30 @@ func TestStaticFS(t *testing.T) { assert.Equal(t, http.StatusOK, w.Code) } + +func TestLoadHTMLGlob(t *testing.T) { + LoadHTMLGlob("../testdata/template/*.tmpl") +} + +func TestLoadHTMLFiles(t *testing.T) { + LoadHTMLFiles("../testdata/template/hello.tmpl") +} + +func TestLoadHTMLFS(t *testing.T) { + LoadHTMLFS(http.Dir("../testdata/template"), "hello.tmpl") +} + +func TestRunInvalidAddress(t *testing.T) { + err := Run("invalid:address:format") + assert.Error(t, err) +} + +func TestRunTLSInvalid(t *testing.T) { + err := RunTLS("invalid:address:format", "nonexistent.crt", "nonexistent.key") + assert.Error(t, err) +} + +func TestRunUnixInvalid(t *testing.T) { + err := RunUnix("/nonexistent/path/socket.sock") + assert.Error(t, err) +}