Skip to content

Commit

Permalink
adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Dec 28, 2023
1 parent 98ad670 commit 821c37c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/webapi/webapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ func TestServer_deleteSampleHandler(t *testing.T) {
assert.Equal(t, http.StatusOK, rr.Code, "handler returned wrong status code")
body := rr.Body.String()
t.Log(body)
assert.Contains(t, body, "<h4>Spam Samples</h4>", "response should contain spam samples")
assert.Contains(t, body, "<h4>Ham Samples</h4>", "response should contain ham samples")
assert.Contains(t, body, "<h4>Spam Samples (2)</h4>", "response should contain spam samples")
assert.Contains(t, body, "<h4>Ham Samples (2)</h4>", "response should contain ham samples")
require.Equal(t, 1, len(spamFilterMock.RemoveDynamicHamSampleCalls()))
assert.Equal(t, "test message", spamFilterMock.RemoveDynamicHamSampleCalls()[0].Sample)
})
Expand Down Expand Up @@ -657,7 +657,7 @@ func TestServer_updateApprovedUsersHandler(t *testing.T) {
assert.Equal(t, http.StatusOK, rr.Code, "handler returned wrong status code")
body := rr.Body.String()
t.Log(body)
assert.Contains(t, body, "<h4>Approved Users</h4>", "response should contain approved users header")
assert.Contains(t, body, "<h4>Approved Users (2)</h4>", "response should contain approved users header")
assert.Contains(t, body, "user1")
assert.Contains(t, body, "user2")

Expand Down Expand Up @@ -816,7 +816,7 @@ func TestServer_htmlManageUsersHandler(t *testing.T) {
assert.Equal(t, http.StatusOK, rr.Code, "handler should return status OK")
body := rr.Body.String()
assert.Contains(t, body, "<title>Manage Users - TG-Spam</title>", "template should contain the correct title")
assert.Contains(t, body, "<h4>Approved Users</h4>", "template should contain users list")
assert.Contains(t, body, "<h4>Approved Users (2)</h4>", "template should contain users list")
}

func TestServer_stylesHandler(t *testing.T) {
Expand Down Expand Up @@ -1003,10 +1003,10 @@ func TestServer_renderSamples(t *testing.T) {
assert.Equal(t, http.StatusOK, w.Code)
assert.Equal(t, "text/html; charset=utf-8", w.Header().Get("Content-Type"))
t.Log(w.Body.String())
assert.Contains(t, w.Body.String(), "<h4>Spam Samples</h4>")
assert.Contains(t, w.Body.String(), "<h4>Spam Samples (2)</h4>")
assert.Contains(t, w.Body.String(), "spam1")
assert.Contains(t, w.Body.String(), "spam2")
assert.Contains(t, w.Body.String(), "<h4>Ham Samples</h4>")
assert.Contains(t, w.Body.String(), "<h4>Ham Samples (2)</h4>")
assert.Contains(t, w.Body.String(), "ham1")
assert.Contains(t, w.Body.String(), "ham2")
}

0 comments on commit 821c37c

Please sign in to comment.