mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
mount-utils: fix linter warnings in tests
Mostly "return value is not checked". Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
8ced101db5
commit
cfbc5dc54f
@ -41,8 +41,7 @@ func TestDoCleanupMountPoint(t *testing.T) {
|
|||||||
// and error if the prepare function encountered a fatal error.
|
// and error if the prepare function encountered a fatal error.
|
||||||
prepareMnt func(base string) (MountPoint, error, error)
|
prepareMnt func(base string) (MountPoint, error, error)
|
||||||
// Function that prepares the FakeMounter for the test.
|
// Function that prepares the FakeMounter for the test.
|
||||||
// Returns error if prepareMntr function encountered a fatal error.
|
prepareMntr func(mntr *FakeMounter)
|
||||||
prepareMntr func(mntr *FakeMounter) error
|
|
||||||
expectErr bool
|
expectErr bool
|
||||||
}{
|
}{
|
||||||
"mount-ok": {
|
"mount-ok": {
|
||||||
@ -94,9 +93,8 @@ func TestDoCleanupMountPoint(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return MountPoint{Device: "/dev/sdb", Path: path}, nil, nil
|
return MountPoint{Device: "/dev/sdb", Path: path}, nil, nil
|
||||||
},
|
},
|
||||||
prepareMntr: func(mntr *FakeMounter) error {
|
prepareMntr: func(mntr *FakeMounter) {
|
||||||
mntr.WithSkipMountPointCheck()
|
mntr.WithSkipMountPointCheck()
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
},
|
},
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
utilexec "k8s.io/utils/exec"
|
utilexec "k8s.io/utils/exec"
|
||||||
testexec "k8s.io/utils/exec/testing"
|
testexec "k8s.io/utils/exec/testing"
|
||||||
)
|
)
|
||||||
@ -436,15 +437,17 @@ func TestSearchMountPoints(t *testing.T) {
|
|||||||
defer os.Remove(tmpFile.Name())
|
defer os.Remove(tmpFile.Name())
|
||||||
defer tmpFile.Close()
|
defer tmpFile.Close()
|
||||||
for _, v := range testcases {
|
for _, v := range testcases {
|
||||||
tmpFile.Truncate(0)
|
assert.NoError(t, tmpFile.Truncate(0))
|
||||||
tmpFile.Seek(0, 0)
|
_, err := tmpFile.Seek(0, 0)
|
||||||
tmpFile.WriteString(v.mountInfos)
|
assert.NoError(t, err)
|
||||||
tmpFile.Sync()
|
_, err = tmpFile.WriteString(v.mountInfos)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.NoError(t, tmpFile.Sync())
|
||||||
refs, err := SearchMountPoints(v.source, tmpFile.Name())
|
refs, err := SearchMountPoints(v.source, tmpFile.Name())
|
||||||
if !reflect.DeepEqual(refs, v.expectedRefs) {
|
if !reflect.DeepEqual(refs, v.expectedRefs) {
|
||||||
t.Errorf("test %q: expected Refs: %#v, got %#v", v.name, v.expectedRefs, refs)
|
t.Errorf("test %q: expected Refs: %#v, got %#v", v.name, v.expectedRefs, refs)
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(err, v.expectedErr) {
|
if err != v.expectedErr {
|
||||||
t.Errorf("test %q: expected err: %v, got %v", v.name, v.expectedErr, err)
|
t.Errorf("test %q: expected err: %v, got %v", v.name, v.expectedErr, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -703,7 +706,10 @@ func TestFormatConcurrency(t *testing.T) {
|
|||||||
// for one to be released
|
// for one to be released
|
||||||
for i := 0; i < tc.max+1; i++ {
|
for i := 0; i < tc.max+1; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
mounter.format(fstype, nil)
|
_, err := mounter.format(fstype, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("format(%q): %v", fstype, err)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,7 +784,10 @@ func TestFormatTimeout(t *testing.T) {
|
|||||||
|
|
||||||
for i := 0; i < maxConcurrency+1; i++ {
|
for i := 0; i < maxConcurrency+1; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
mounter.format(fstype, nil)
|
_, err := mounter.format(fstype, nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("format(%q): %v", fstype, err)
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user