mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55:24 +00:00
fix: finish 2.9.0 plugin moves and get every check green
This commit is contained in:
1 parent
8c1e02af89
commit
6489b62ece
335 files changed
+29878
-17749
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
clearTransferProfiles,
|
||||
flushTransferProfiles,
|
||||
getTransferProfile,
|
||||
initializeTransferProfiles,
|
||||
recordTransferProfile,
|
||||
setTransferProfileStore,
|
||||
type PersistedProfiles,
|
||||
} from "../../src/backend/transfer-tuning.js";
|
||||
|
||||
afterEach(() => {
|
||||
setTransferProfileStore(null);
|
||||
clearTransferProfiles();
|
||||
});
|
||||
|
||||
function memoryStore() {
|
||||
let saved: PersistedProfiles | undefined;
|
||||
return {
|
||||
store: {
|
||||
read: async () => saved,
|
||||
write: async (value: PersistedProfiles) => {
|
||||
saved = JSON.parse(JSON.stringify(value));
|
||||
},
|
||||
},
|
||||
saved: () => saved,
|
||||
};
|
||||
}
|
||||
|
||||
describe("transfer profile store", () => {
|
||||
it("saves learned profiles and reads them back after a restart", async () => {
|
||||
const memory = memoryStore();
|
||||
setTransferProfileStore(memory.store);
|
||||
await initializeTransferProfiles();
|
||||
|
||||
recordTransferProfile("host-a:host-b", {
|
||||
bytes: 50 * 1024 * 1024,
|
||||
durationMs: 5000,
|
||||
lanes: 4,
|
||||
pipelineConcurrency: 8,
|
||||
failed: false,
|
||||
now: Date.now(),
|
||||
});
|
||||
await flushTransferProfiles();
|
||||
expect(Object.keys(memory.saved()?.profiles ?? {})).toHaveLength(1);
|
||||
|
||||
// A fresh activation starts from what the store holds.
|
||||
setTransferProfileStore(memory.store);
|
||||
await initializeTransferProfiles();
|
||||
expect(getTransferProfile("host-a:host-b")).toBeDefined();
|
||||
});
|
||||
|
||||
it("works without a store", async () => {
|
||||
await initializeTransferProfiles();
|
||||
expect(getTransferProfile("nothing")).toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user