mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-05-23 15:27:38 +02:00
Add Access Tokens UI
This commit is contained in:
parent
62140ec001
commit
16c14bf709
19 changed files with 643 additions and 132 deletions
util
|
@ -190,13 +190,25 @@ func TestReadJSON_Failure(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestReadJSONWithLimit_Success(t *testing.T) {
|
||||
v, err := UnmarshalJSONWithLimit[testJSON](io.NopCloser(strings.NewReader(`{"name":"some name","something":99}`)), 100)
|
||||
v, err := UnmarshalJSONWithLimit[testJSON](io.NopCloser(strings.NewReader(`{"name":"some name","something":99}`)), 100, false)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, "some name", v.Name)
|
||||
require.Equal(t, 99, v.Something)
|
||||
}
|
||||
|
||||
func TestReadJSONWithLimit_FailureTooLong(t *testing.T) {
|
||||
_, err := UnmarshalJSONWithLimit[testJSON](io.NopCloser(strings.NewReader(`{"name":"some name","something":99}`)), 10)
|
||||
_, err := UnmarshalJSONWithLimit[testJSON](io.NopCloser(strings.NewReader(`{"name":"some name","something":99}`)), 10, false)
|
||||
require.Equal(t, ErrTooLargeJSON, err)
|
||||
}
|
||||
|
||||
func TestReadJSONWithLimit_AllowEmpty(t *testing.T) {
|
||||
v, err := UnmarshalJSONWithLimit[testJSON](io.NopCloser(strings.NewReader(` `)), 10, true)
|
||||
require.Nil(t, err)
|
||||
require.Equal(t, "", v.Name)
|
||||
require.Equal(t, 0, v.Something)
|
||||
}
|
||||
|
||||
func TestReadJSONWithLimit_NoAllowEmpty(t *testing.T) {
|
||||
_, err := UnmarshalJSONWithLimit[testJSON](io.NopCloser(strings.NewReader(` `)), 10, false)
|
||||
require.Equal(t, ErrUnmarshalJSON, err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue