Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ostcar committed Aug 28, 2023
1 parent 3579cd9 commit 51e9f20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
24 changes: 12 additions & 12 deletions vote/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@ func loadPoll(ctx context.Context, ds *dsfetch.Fetch, pollID int) (pollConfig, e
// preload loads all data in the cache, that is needed later for the vote
// requests.
func (p pollConfig) preload(ctx context.Context, ds *dsfetch.Fetch) error {
ds.Meeting_UsersEnableVoteWeight(p.meetingID)
ds.Meeting_UsersEnableVoteDelegations(p.meetingID)
ds.Meeting_UsersEnableVoteWeight(p.meetingID).Preload()
ds.Meeting_UsersEnableVoteDelegations(p.meetingID).Preload()

meetingUserIDsList := make([][]int, len(p.groups))
for i, groupID := range p.groups {
Expand All @@ -586,10 +586,10 @@ func (p pollConfig) preload(ctx context.Context, ds *dsfetch.Fetch) error {
var uid int
userIDs = append(userIDs, &uid)
ds.MeetingUser_UserID(muID).Lazy(&uid)
ds.MeetingUser_GroupIDs(muID)
ds.MeetingUser_VoteWeight(muID)
ds.MeetingUser_VoteDelegatedToID(muID)
ds.MeetingUser_MeetingID(muID)
ds.MeetingUser_GroupIDs(muID).Preload()
ds.MeetingUser_VoteWeight(muID).Preload()
ds.MeetingUser_VoteDelegatedToID(muID).Preload()
ds.MeetingUser_MeetingID(muID).Preload()
}
}

Expand Down Expand Up @@ -617,7 +617,7 @@ func (p pollConfig) preload(ctx context.Context, ds *dsfetch.Fetch) error {
delegatedUserIDs := make([]int, len(delegatedMeetingUserIDs))
for i, muID := range delegatedMeetingUserIDs {
ds.MeetingUser_UserID(muID).Lazy(&delegatedUserIDs[i])
ds.MeetingUser_MeetingID(muID)
ds.MeetingUser_MeetingID(muID).Preload()
}

// Third database request to get all delegated user ids. Only fetches data
Expand All @@ -627,13 +627,13 @@ func (p pollConfig) preload(ctx context.Context, ds *dsfetch.Fetch) error {
}

for _, uID := range userIDs {
ds.User_DefaultVoteWeight(*uID)
ds.User_MeetingUserIDs(*uID)
ds.User_IsPresentInMeetingIDs(*uID)
ds.User_DefaultVoteWeight(*uID).Preload()
ds.User_MeetingUserIDs(*uID).Preload()
ds.User_IsPresentInMeetingIDs(*uID).Preload()
}
for _, uID := range delegatedUserIDs {
ds.User_IsPresentInMeetingIDs(uID)
ds.User_MeetingUserIDs(uID)
ds.User_IsPresentInMeetingIDs(uID).Preload()
ds.User_MeetingUserIDs(uID).Preload()
}

// Thrid or forth database request to get is present_in_meeting for all users and delegates.
Expand Down
9 changes: 1 addition & 8 deletions vote/vote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestVoteStart(t *testing.T) {
type: pseudoanonymous
pollmethod: Y
group/1/user_ids: [1]
user/1/is_present_in_meeting_ids: [1]
meeting/5/id: 5
`),
Expand Down Expand Up @@ -75,7 +74,6 @@ func TestVoteStart(t *testing.T) {
backend: fast
pollmethod: Y
group/1/user_ids: [1]
user/1/is_present_in_meeting_ids: [1]
meeting/5/id: 5
`)}
Expand All @@ -98,7 +96,6 @@ func TestVoteStart(t *testing.T) {
backend: fast
pollmethod: Y
group/1/user_ids: [1]
user/1/is_present_in_meeting_ids: [1]
meeting/5/id: 5
`)}
Expand All @@ -125,7 +122,6 @@ func TestVoteStart(t *testing.T) {
backend: fast
pollmethod: Y
group/1/user_ids: [1]
user/1/is_present_in_meeting_ids: [1]
`)}
v, _, _ := vote.New(ctx, backend, backend, ds, true)
Expand All @@ -148,7 +144,6 @@ func TestVoteStart(t *testing.T) {
backend: fast
pollmethod: Y
group/1/user_ids: [1]
user/1/is_present_in_meeting_ids: [1]
meeting/5/id: 5
`)}
Expand All @@ -171,7 +166,6 @@ func TestVoteStart(t *testing.T) {
backend: fast
pollmethod: Y
group/1/user_ids: [1]
user/1/is_present_in_meeting_ids: [1]
`)}
v, _, _ := vote.New(ctx, backend, backend, ds, true)
Expand All @@ -194,7 +188,6 @@ func TestVoteStart(t *testing.T) {
backend: fast
pollmethod: Y
group/1/user_ids: [1]
user/1/is_present_in_meeting_ids: [1]
`)}
v, _, _ := vote.New(ctx, backend, backend, ds, true)
Expand Down Expand Up @@ -503,7 +496,7 @@ func TestVoteNoRequests(t *testing.T) {
meeting_user:
10:
user_id: 1
vote_delegated_from_ids: [20]
vote_delegations_from_ids: [20]
meeting_id: 50
20:
meeting_id: 50
Expand Down

0 comments on commit 51e9f20

Please sign in to comment.