Skip to content

Commit

Permalink
state, filter: Introduce unit tests for numeric iface names
Browse files Browse the repository at this point in the history
Interfaces names with numeric values are accepted by the kernel.
Introduce tests that checks the behavior when using numeric names.

Signed-off-by: Edward Haas <[email protected]>
  • Loading branch information
EdDev committed Mar 3, 2021
1 parent d5025ef commit 8165846
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/state/filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,32 @@ interfaces:
})
})

Context("when the interfaces has numeric characters quoted", func() {
BeforeEach(func() {
state = nmstate.NewState(`
interfaces:
- name: eth0
- name: '0'
- name: '1101010'
- name: '0.0'
- name: '1.0'
- name: '0xfe'
- name: '60.e+02'
`)
filteredState = nmstate.NewState(`
interfaces:
- name: eth0
- name: '1101010'
- name: '1.0'
- name: '60.e+02'
`)
interfacesFilterGlob = glob.MustCompile("0*")
})

It("should filter out interfaces correctly", func() {
returnedState, err := filterOut(state, interfacesFilterGlob)
Expect(err).NotTo(HaveOccurred())
Expect(returnedState).To(MatchYAML(filteredState))
})
})
})

0 comments on commit 8165846

Please sign in to comment.