Skip to content

Commit

Permalink
Avoid panicking in tests (#204)
Browse files Browse the repository at this point in the history
Using Gomega assertions makes test errors more readable.

Upgrade GolangCI to v.1.45 to avoid errors like:
"export data is newer version - update tool"

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
  • Loading branch information
zeeke authored May 17, 2022
1 parent faf2d00 commit d5784b1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/static-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.29
version: v1.45
# Adding additional linters beside the default set - See https://golangci-lint.run/usage/linters
args: --enable=golint,bodyclose,gosec,whitespace
shellcheck:
Expand Down
9 changes: 2 additions & 7 deletions pkg/config/config_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (
. "github.com/onsi/gomega"
)

func check(e error) {
if e != nil {
panic(e)
}
}
func TestConfig(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Config Suite")
Expand All @@ -21,10 +16,10 @@ func TestConfig(t *testing.T) {
var _ = BeforeSuite(func() {
// create test sys tree
err := utils.CreateTmpSysFs()
check(err)
Expect(err).Should(Succeed())
})

var _ = AfterSuite(func() {
err := utils.RemoveTmpSysFs()
check(err)
Expect(err).Should(Succeed())
})
9 changes: 2 additions & 7 deletions pkg/sriov/sriov_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ import (
"testing"
)

func check(e error) {
if e != nil {
panic(e)
}
}
func TestConfig(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Sriov Suite")
Expand All @@ -21,10 +16,10 @@ func TestConfig(t *testing.T) {
var _ = BeforeSuite(func() {
// create test sys tree
err := utils.CreateTmpSysFs()
check(err)
Expect(err).Should(Succeed())
})

var _ = AfterSuite(func() {
err := utils.RemoveTmpSysFs()
check(err)
Expect(err).Should(Succeed())
})
6 changes: 0 additions & 6 deletions pkg/utils/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import (
"syscall"
)

func check(e error) {
if e != nil {
panic(e)
}
}

type tmpSysFs struct {
dirRoot string
dirList []string
Expand Down
4 changes: 2 additions & 2 deletions pkg/utils/utils_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func TestUtils(t *testing.T) {
var _ = BeforeSuite(func() {
// create test sys tree
err := CreateTmpSysFs()
check(err)
Expect(err).Should(Succeed())
})

var _ = AfterSuite(func() {
err := RemoveTmpSysFs()
check(err)
Expect(err).Should(Succeed())
})

0 comments on commit d5784b1

Please sign in to comment.