1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

source: make per-source unit tests stricter

Now the tests check that GetLabels() works even without calling
Discover() at all.
This commit is contained in:
Markus Lehtonen 2021-12-03 10:26:26 +02:00
parent 14ab512588
commit a5e2d4ca16
9 changed files with 9 additions and 18 deletions

View file

@ -20,14 +20,13 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
)
func TestCpuSource(t *testing.T) {
assert.Equal(t, src.Name(), Name)
// Check that GetLabels works with empty features
src.features = feature.NewDomainFeatures()
src.features = nil
l, err := src.GetLabels()
assert.Nil(t, err, err)

View file

@ -20,14 +20,13 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
)
func TestKernelSource(t *testing.T) {
assert.Equal(t, src.Name(), Name)
// Check that GetLabels works with empty features
src.features = feature.NewDomainFeatures()
src.features = nil
l, err := src.GetLabels()
assert.Nil(t, err, err)

View file

@ -20,14 +20,13 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
)
func TestLocalSource(t *testing.T) {
assert.Equal(t, src.Name(), Name)
// Check that GetLabels works with empty features
src.features = feature.NewDomainFeatures()
src.features = nil
l, err := src.GetLabels()
assert.Nil(t, err, err)

View file

@ -20,14 +20,13 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
)
func TestMemorySource(t *testing.T) {
assert.Equal(t, src.Name(), Name)
// Check that GetLabels works with empty features
src.features = feature.NewDomainFeatures()
src.features = nil
l, err := src.GetLabels()
assert.Nil(t, err, err)

View file

@ -20,14 +20,13 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
)
func TestNetworkSource(t *testing.T) {
assert.Equal(t, src.Name(), Name)
// Check that GetLabels works with empty features
src.features = feature.NewDomainFeatures()
src.features = nil
l, err := src.GetLabels()
assert.Nil(t, err, err)

View file

@ -20,14 +20,13 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
)
func TestPciSource(t *testing.T) {
assert.Equal(t, src.Name(), Name)
// Check that GetLabels works with empty features
src.features = feature.NewDomainFeatures()
src.features = nil
l, err := src.GetLabels()
assert.Nil(t, err, err)

View file

@ -20,14 +20,13 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
)
func TestStorageSource(t *testing.T) {
assert.Equal(t, src.Name(), Name)
// Check that GetLabels works with empty features
src.features = feature.NewDomainFeatures()
src.features = nil
l, err := src.GetLabels()
assert.Nil(t, err, err)

View file

@ -20,14 +20,13 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
)
func TestSystemSource(t *testing.T) {
assert.Equal(t, src.Name(), Name)
// Check that GetLabels works with empty features
src.features = feature.NewDomainFeatures()
src.features = nil
l, err := src.GetLabels()
assert.Nil(t, err, err)

View file

@ -20,14 +20,13 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"sigs.k8s.io/node-feature-discovery/pkg/api/feature"
)
func TestUsbSource(t *testing.T) {
assert.Equal(t, src.Name(), Name)
// Check that GetLabels works with empty features
src.features = feature.NewDomainFeatures()
src.features = nil
l, err := src.GetLabels()
assert.Nil(t, err, err)