Skip to content

Commit

Permalink
Add some specs for OpenBSD operating system
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-carlborg committed Dec 12, 2023
1 parent 24a0c6e commit be61fd4
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 17 deletions.
7 changes: 1 addition & 6 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.

98 changes: 98 additions & 0 deletions spec/operating_systems/openbsd/openbsd.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import OpenBsd from '../../../src/operating_systems/openbsd/openbsd'
import hostModule from '../../../src/host'
import * as arch from '../../../src/architecture'
import * as os from '../../../src/operating_systems/kind'
import {SshConfigurationKind} from '../../../src/action/action'
import {Host} from '../../../src/host'

let context = describe

describe('OpenBSD OperatingSystem', () => {
let osKind = os.Kind.for('openbsd')

describe('actionImplementationKind', () => {
context('when on a macOS host', () => {
let host = Host.create('darwin')

context('when the architecture is x86_64', () => {
let architecture = arch.Architecture.for(
arch.Kind.x86_64,
host,
osKind,
host.hypervisor
)
let openbsd = new OpenBsd(architecture, '0.0.0')

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

it('returns the "xhyve" SSH config kind', () => {
const result = openbsd.actionImplementationKind
expect(result).toEqual(SshConfigurationKind.xhyve)
})
})

context('when the architecture is not x86_64', () => {
let architecture = arch.Architecture.for(
arch.Kind.arm64,
host,
osKind,
host.hypervisor
)
let openbsd = new OpenBsd(architecture, '0.0.0')

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

it('returns the "qemu" SSH config kind', () => {
const result = openbsd.actionImplementationKind
expect(result).toEqual(SshConfigurationKind.qemu)
})
})
})

context('when on a Linux host', () => {
let host = Host.create('linux')

context('when the architecture is x86_64', () => {
let architecture = arch.Architecture.for(
arch.Kind.x86_64,
host,
osKind,
host.hypervisor
)
let openbsd = new OpenBsd(architecture, '0.0.0')

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

it('returns the "qemu" SSH config kind', () => {
const result = openbsd.actionImplementationKind
expect(result).toEqual(SshConfigurationKind.qemu)
})
})

context('when the architecture is not x86_64', () => {
let architecture = arch.Architecture.for(
arch.Kind.arm64,
host,
osKind,
host.hypervisor
)
let openbsd = new OpenBsd(architecture, '0.0.0')

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

it('returns the "qemu" SSH config kind', () => {
const result = openbsd.actionImplementationKind
expect(result).toEqual(SshConfigurationKind.qemu)
})
})
})
})
})
11 changes: 1 addition & 10 deletions src/operating_systems/openbsd/openbsd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,7 @@ export default class OpenBsd extends os.OperatingSystem {
default: defaultKind
})

const result = host.hypervisor.resolve({
xhyve: archResult,
default: defaultKind
})

core.debug(
`actionImplementationKind result: ${action.SshConfigurationKind[result]}`
)

return result
return host.resolve({macos: archResult, default: defaultKind})
}

override async prepareDisk(
Expand Down

0 comments on commit be61fd4

Please sign in to comment.