fix tests for votes default value
This commit is contained in:
@@ -107,6 +107,7 @@ func TestBoltAdmin_DeleteUser(t *testing.T) {
|
||||
|
||||
b, teardown := prep(t)
|
||||
defer teardown()
|
||||
|
||||
err := b.DeleteUser("radio-t", "user1")
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -157,6 +158,7 @@ func TestBoltAdmin_BlockUserWithTTL(t *testing.T) {
|
||||
|
||||
b, teardown := prep(t)
|
||||
defer teardown()
|
||||
|
||||
assert.False(t, b.IsBlocked("radio-t", "user1"), "nothing blocked")
|
||||
assert.NoError(t, b.SetBlock("radio-t", "user1", true, 50*time.Millisecond))
|
||||
assert.True(t, b.IsBlocked("radio-t", "user1"), "user1 blocked")
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestService_CreateFromEmpty(t *testing.T) {
|
||||
assert.Equal(t, "user", res.User.ID)
|
||||
assert.Equal(t, "name", res.User.Name)
|
||||
assert.Equal(t, "23f97cf4d5c29ef788ca2bdd1c9e75656c0e4149", res.User.IP)
|
||||
assert.Equal(t, map[string]bool{}, res.Votes)
|
||||
assert.Equal(t, map[string]bool(nil), res.Votes)
|
||||
}
|
||||
|
||||
func TestService_CreateFromPartial(t *testing.T) {
|
||||
@@ -174,7 +174,7 @@ func TestService_Vote(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 3, len(res))
|
||||
assert.Equal(t, 0, res[0].Score)
|
||||
assert.Equal(t, map[string]bool{}, res[0].Votes, "no votes initially")
|
||||
assert.Equal(t, map[string]bool(nil), res[0].Votes, "no votes initially")
|
||||
|
||||
c, err := b.Vote(store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, res[0].ID, "user1", true)
|
||||
assert.Nil(t, err)
|
||||
@@ -200,7 +200,7 @@ func TestService_Vote(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 3, len(res))
|
||||
assert.Equal(t, 0, res[0].Score)
|
||||
assert.Equal(t, map[string]bool{}, res[0].Votes, "vote reset ok")
|
||||
assert.Equal(t, map[string]bool(nil), res[0].Votes, "vote reset ok")
|
||||
}
|
||||
|
||||
func TestService_VoteLimit(t *testing.T) {
|
||||
@@ -246,7 +246,7 @@ func TestService_VoteAggressive(t *testing.T) {
|
||||
t.Logf("%+v", res[0])
|
||||
assert.Equal(t, 3, len(res))
|
||||
assert.Equal(t, 0, res[0].Score)
|
||||
assert.Equal(t, map[string]bool{}, res[0].Votes, "no votes initially")
|
||||
assert.Equal(t, map[string]bool(nil), res[0].Votes, "no votes initially")
|
||||
|
||||
// add a vote as user2
|
||||
_, err = b.Vote(store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, res[0].ID, "user2", true)
|
||||
@@ -258,7 +258,8 @@ func TestService_VoteAggressive(t *testing.T) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
b.Vote(store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, res[0].ID, "user1", true)
|
||||
_, _ = b.Vote(store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, res[0].ID, "user1", true)
|
||||
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
@@ -277,7 +278,7 @@ func TestService_VoteAggressive(t *testing.T) {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
val := rand.Intn(2) > 0
|
||||
b.Vote(store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, res[0].ID, "user1", val)
|
||||
_, _ = b.Vote(store.Locator{URL: "https://radio-t.com", SiteID: "radio-t"}, res[0].ID, "user1", val)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
Reference in New Issue
Block a user