Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
recap committed May 30, 2024
1 parent 61f3d1c commit 8053332
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion schedulers/gat-scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class GatScheduler {
return Object.values(experiment.servers).some((s) => s.length >= this.min)
}

async checkConditionAndReturnUsers(experiments, usedUrls) {
checkConditionAndReturnUsers(experiments, usedUrls) {
// await this.queue.wait()
const queueSize = this.queue.size()
const falseCondition = {
Expand Down
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function agreeGame(users, uuid, agreement, usersDb) {
}
}

async function startReadyGames(experiments, agreementIds, usersDb) {
function startReadyGames(experiments, agreementIds, usersDb) {
for (const [experimentId, _] of Object.entries(experiments)) {
const experiment = experiments[experimentId]
const scheduler = experiment.scheduler
Expand All @@ -276,7 +276,7 @@ async function startReadyGames(experiments, agreementIds, usersDb) {
let canMaybeScheduleNext = true
while (canMaybeScheduleNext) {
canMaybeScheduleNext = false
const conditionObject = await scheduler.checkConditionAndReturnUsers(
const conditionObject = scheduler.checkConditionAndReturnUsers(
experiments,
usedUrls,
)
Expand Down
3 changes: 3 additions & 0 deletions test/gat-scheduler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ test("test GAT scheduler with enough rooms", () => {
},
)
users.forEach((user) => {
user.changeState("queued")
scheduler.queueUser(user)
})
assert.strictEqual(scheduler.queue.size(), 7)
Expand Down Expand Up @@ -92,6 +93,7 @@ test("test GAT scheduler without enough rooms", () => {
},
)
users.forEach((user) => {
user.changeState("queued")
scheduler.queueUser(user)
})
assert.strictEqual(scheduler.queue.size(), 7)
Expand Down Expand Up @@ -145,6 +147,7 @@ test("test GAT scheduler with used URLs", () => {
return new User(userId, experimentName)
})
users.forEach((user) => {
user.changeState("queued")
scheduler.queueUser(user)
})
assert.strictEqual(scheduler.queue.size(), 3)
Expand Down
2 changes: 1 addition & 1 deletion user.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class User {
reset() {
if (this.state === "inoTreePages") {
console.log(
`[${this.userId}] Resetting user while in state ${this.state}.`
`[${this.userId}] Resetting user while in state ${this.state}.`,
)
}
this.state = "startedPage"
Expand Down

0 comments on commit 8053332

Please sign in to comment.