Skip to content

Commit

Permalink
Wrap host module in namespace
Browse files Browse the repository at this point in the history
This allows to have a global getter.
  • Loading branch information
jacob-carlborg committed Dec 14, 2023
1 parent 87fdd34 commit 9894a9b
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 199 deletions.
165 changes: 84 additions & 81 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

38 changes: 4 additions & 34 deletions spec/operating_systems/freebsd/freebsd.spec.ts
@@ -1,46 +1,16 @@
import {basename} from 'path'

import FreeBsd from '../../../src/operating_systems/freebsd/freebsd'
import * as hostModule from '../../../src/host'
import hostModule from '../../../src/host'
import * as arch from '../../../src/architecture'
import * as os from '../../../src/operating_systems/kind'
import {Accelerator} from '../../../src/vm'
import HostQemu from '../../../src/host_qemu'
import * as hypervisor from '../../../src/hypervisor'
import * as qemu from '../../../src/qemu_vm'
import * as xhyve from '../../../src/xhyve_vm'
import {Input} from '../../../src/action/input'
import {Host} from '../../../src/host'

describe('FreeBSD OperatingSystem', () => {
class MockHost extends hostModule.Host {
get vmModule(): typeof xhyve | typeof qemu {
return qemu
}

override get qemu(): HostQemu {
return new HostQemu.LinuxHostQemu()
}

override get hypervisor(): hypervisor.Hypervisor {
return new hypervisor.Qemu()
}

override get efiHypervisor(): hypervisor.Hypervisor {
return new hypervisor.QemuEfi()
}

override get defaultMemory(): string {
return '6G'
}

override get defaultCpuCount(): number {
return 6
}

override validateHypervisor(_kind: hypervisor.Kind): void {}
}

let host = new MockHost()
let host = Host.create('linux')
let osKind = os.Kind.for('freebsd')
let vmm = host.hypervisor
let architecture = arch.Architecture.for(arch.Kind.x86_64, host, osKind, vmm)
Expand All @@ -62,7 +32,7 @@ describe('FreeBSD OperatingSystem', () => {
let vmModule = jasmine.createSpy('vmModule')

beforeEach(() => {
spyOn(hostModule, 'getHost').and.returnValue(host)
spyOnProperty(hostModule, 'host').and.returnValue(host)
})

it('creates a virtual machine with the correct configuration', () => {
Expand Down

0 comments on commit 9894a9b

Please sign in to comment.