mirror of
https://github.com/prometheus/prometheus
synced 2026-04-20 22:41:05 +08:00
Merge pull request #18519 from alliasgher/fix-testfstype-unknown-fs
util/runtime: let TestFsType tolerate filesystems absent from FsType map
This commit is contained in:
@@ -19,20 +19,18 @@ import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/regexp"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
var regexpFsType = regexp.MustCompile("^[A-Z][A-Z0-9_]*_MAGIC$")
|
||||
|
||||
func TestFsType(t *testing.T) {
|
||||
var fsType string
|
||||
|
||||
path, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
|
||||
// A real path must yield a non-zero filesystem type.
|
||||
fsType = FsType(path)
|
||||
require.Regexp(t, regexpFsType, fsType)
|
||||
require.NotEqual(t, "0", fsType)
|
||||
|
||||
fsType = FsType("/no/where/to/be/found")
|
||||
require.Equal(t, "0", fsType)
|
||||
|
||||
Reference in New Issue
Block a user