Remove quota disabling, it didn't have much of an effect.
This commit is contained in:
parent
84542dd808
commit
e38d4c1e48
|
@ -1 +1 @@
|
||||||
Subproject commit bec35b4c27ec10fe31dc07f9d42d8bda426b8535
|
Subproject commit b28dbd549284cf450be7f25ad85aadf614d08f0b
|
|
@ -177,28 +177,26 @@ if (descriptions.length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function expectRowUsage(expected: number, f: () => Promise<void>) {
|
async function expectRowUsage(expected: number, f: () => Promise<void>) {
|
||||||
return await quotas.withEnabled(async () => {
|
const before = await getRowUsage()
|
||||||
const before = await getRowUsage()
|
await f()
|
||||||
await f()
|
const after = await getRowUsage()
|
||||||
const after = await getRowUsage()
|
const usage = after - before
|
||||||
const usage = after - before
|
|
||||||
|
|
||||||
// Because our quota tracking is not perfect, we allow a 10% margin of
|
// Because our quota tracking is not perfect, we allow a 10% margin of
|
||||||
// error. This is to account for the fact that parallel writes can
|
// error. This is to account for the fact that parallel writes can
|
||||||
// result in some quota updates getting lost. We don't have any need
|
// result in some quota updates getting lost. We don't have any need
|
||||||
// to solve this right now, so we just allow for some error.
|
// to solve this right now, so we just allow for some error.
|
||||||
if (expected === 0) {
|
if (expected === 0) {
|
||||||
expect(usage).toEqual(0)
|
expect(usage).toEqual(0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (usage < 0) {
|
if (usage < 0) {
|
||||||
expect(usage).toBeGreaterThan(expected * 1.1)
|
expect(usage).toBeGreaterThan(expected * 1.1)
|
||||||
expect(usage).toBeLessThan(expected * 0.9)
|
expect(usage).toBeLessThan(expected * 0.9)
|
||||||
} else {
|
} else {
|
||||||
expect(usage).toBeGreaterThan(expected * 0.9)
|
expect(usage).toBeGreaterThan(expected * 0.9)
|
||||||
expect(usage).toBeLessThan(expected * 1.1)
|
expect(usage).toBeLessThan(expected * 1.1)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultRowFields = isInternal
|
const defaultRowFields = isInternal
|
||||||
|
|
|
@ -2830,14 +2830,12 @@ if (descriptions.length) {
|
||||||
expected: number,
|
expected: number,
|
||||||
f: () => Promise<T>
|
f: () => Promise<T>
|
||||||
): Promise<T> {
|
): Promise<T> {
|
||||||
return await quotas.withEnabled(async () => {
|
const before = await getRowUsage()
|
||||||
const before = await getRowUsage()
|
const result = await f()
|
||||||
const result = await f()
|
const after = await getRowUsage()
|
||||||
const after = await getRowUsage()
|
const usage = after - before
|
||||||
const usage = after - before
|
expect(usage).toBe(expected)
|
||||||
expect(usage).toBe(expected)
|
return result
|
||||||
return result
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should be able to delete a row", async () => {
|
it("should be able to delete a row", async () => {
|
||||||
|
|
|
@ -44,13 +44,11 @@ describe("test the openai action", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const expectAIUsage = async <T>(expected: number, f: () => Promise<T>) => {
|
const expectAIUsage = async <T>(expected: number, f: () => Promise<T>) => {
|
||||||
return await quotas.withEnabled(async () => {
|
const before = await getAIUsage()
|
||||||
const before = await getAIUsage()
|
const result = await f()
|
||||||
const result = await f()
|
const after = await getAIUsage()
|
||||||
const after = await getAIUsage()
|
expect(after - before).toEqual(expected)
|
||||||
expect(after - before).toEqual(expected)
|
return result
|
||||||
return result
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
it("should be able to receive a response from ChatGPT given a prompt", async () => {
|
it("should be able to receive a response from ChatGPT given a prompt", async () => {
|
||||||
|
|
Loading…
Reference in New Issue