mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-08-16 22:20:30 +03:00
home: imp tests
This commit is contained in:
parent
39b99fc050
commit
3f23c9af47
@ -181,10 +181,10 @@ func TestClientsContainer_HandleAddClient(t *testing.T) {
|
|||||||
body, err := json.Marshal(cj)
|
body, err := json.Marshal(cj)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
rw := httptest.NewRecorder()
|
|
||||||
r, err := http.NewRequest(http.MethodPost, "", bytes.NewReader(body))
|
r, err := http.NewRequest(http.MethodPost, "", bytes.NewReader(body))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
rw := httptest.NewRecorder()
|
||||||
clients.handleAddClient(rw, r)
|
clients.handleAddClient(rw, r)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, tc.wantCode, rw.Code)
|
require.Equal(t, tc.wantCode, rw.Code)
|
||||||
@ -242,11 +242,11 @@ func TestClientsContainer_HandleDelClient(t *testing.T) {
|
|||||||
body, err = json.Marshal(cj)
|
body, err = json.Marshal(cj)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
rw := httptest.NewRecorder()
|
|
||||||
var r *http.Request
|
var r *http.Request
|
||||||
r, err = http.NewRequest(http.MethodPost, "", bytes.NewReader(body))
|
r, err = http.NewRequest(http.MethodPost, "", bytes.NewReader(body))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
rw := httptest.NewRecorder()
|
||||||
clients.handleDelClient(rw, r)
|
clients.handleDelClient(rw, r)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, tc.wantCode, rw.Code)
|
require.Equal(t, tc.wantCode, rw.Code)
|
||||||
@ -319,11 +319,11 @@ func TestClientsContainer_HandleUpdateClient(t *testing.T) {
|
|||||||
body, err = json.Marshal(uj)
|
body, err = json.Marshal(uj)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
rw := httptest.NewRecorder()
|
|
||||||
var r *http.Request
|
var r *http.Request
|
||||||
r, err = http.NewRequest(http.MethodPost, "", bytes.NewReader(body))
|
r, err = http.NewRequest(http.MethodPost, "", bytes.NewReader(body))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
rw := httptest.NewRecorder()
|
||||||
clients.handleUpdateClient(rw, r)
|
clients.handleUpdateClient(rw, r)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, tc.wantCode, rw.Code)
|
require.Equal(t, tc.wantCode, rw.Code)
|
||||||
@ -375,13 +375,12 @@ func TestClientsContainer_HandleFindClient(t *testing.T) {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
rw := httptest.NewRecorder()
|
|
||||||
var r *http.Request
|
var r *http.Request
|
||||||
r, err = http.NewRequest(http.MethodGet, "", nil)
|
r, err = http.NewRequest(http.MethodGet, "", nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
r.URL.RawQuery = tc.query.Encode()
|
r.URL.RawQuery = tc.query.Encode()
|
||||||
|
rw := httptest.NewRecorder()
|
||||||
clients.handleFindClient(rw, r)
|
clients.handleFindClient(rw, r)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, tc.wantCode, rw.Code)
|
require.Equal(t, tc.wantCode, rw.Code)
|
||||||
|
Loading…
Reference in New Issue
Block a user