Skip to content

Commit

Permalink
Add unit tests to cover the retrieval of default user by OS.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarciani committed Oct 17, 2023
1 parent f109a3a commit bd3e25f
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion frontend/src/__tests__/util.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {clamp} from '../util'
import {clamp, clusterDefaultUser} from '../util'
import {mock} from 'jest-mock-extended'
import {ClusterDescription} from '../types/clusters'

describe('Given a function to clamp a number using an option step discretization', () => {
describe('when the input is below the minimum', () => {
Expand Down Expand Up @@ -32,3 +34,45 @@ describe('Given a function to clamp a number using an option step discretization
})
})
})

describe('Given a function to get the default cluster user', () => {
describe('when the OS is Amazon Linux 2', () => {
const cluster = {config: {Image: {Os: 'alinux2'}}}
it('should be ec2-user', () => {
const result = clusterDefaultUser(cluster)
expect(result).toBe('ec2-user')
})
})

describe('when the OS is Ubuntu 18.04', () => {
const cluster = {config: {Image: {Os: 'ubuntu1804'}}}
it('should be ec2-user', () => {
const result = clusterDefaultUser(cluster)
expect(result).toBe('ubuntu')
})
})

describe('when the OS is Ubuntu 20.04', () => {
const cluster = {config: {Image: {Os: 'ubuntu2004'}}}
it('should be ubuntu', () => {
const result = clusterDefaultUser(cluster)
expect(result).toBe('ubuntu')
})
})

describe('when the OS is Ubuntu 22.04', () => {
const cluster = {config: {Image: {Os: 'ubuntu2204'}}}
it('should be ubuntu', () => {
const result = clusterDefaultUser(cluster)
expect(result).toBe('ubuntu')
})
})

describe('when the OS is Centos 7', () => {
const cluster = {config: {Image: {Os: 'centos7'}}}
it('should be centos', () => {
const result = clusterDefaultUser(cluster)
expect(result).toBe('centos')
})
})
})

0 comments on commit bd3e25f

Please sign in to comment.