From a5e2d4ca16c74991cb2822d2c7bf2fa421ed4fa5 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Fri, 3 Dec 2021 10:26:26 +0200 Subject: [PATCH] source: make per-source unit tests stricter Now the tests check that GetLabels() works even without calling Discover() at all. --- source/cpu/cpu_test.go | 3 +-- source/kernel/kernel_test.go | 3 +-- source/local/local_test.go | 3 +-- source/memory/memory_test.go | 3 +-- source/network/network_test.go | 3 +-- source/pci/pci_test.go | 3 +-- source/storage/storage_test.go | 3 +-- source/system/system_test.go | 3 +-- source/usb/usb_test.go | 3 +-- 9 files changed, 9 insertions(+), 18 deletions(-) diff --git a/source/cpu/cpu_test.go b/source/cpu/cpu_test.go index cfb6384c6..3fb401e07 100644 --- a/source/cpu/cpu_test.go +++ b/source/cpu/cpu_test.go @@ -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) diff --git a/source/kernel/kernel_test.go b/source/kernel/kernel_test.go index eef3064d6..51fc3d686 100644 --- a/source/kernel/kernel_test.go +++ b/source/kernel/kernel_test.go @@ -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) diff --git a/source/local/local_test.go b/source/local/local_test.go index 004492035..e83493c63 100644 --- a/source/local/local_test.go +++ b/source/local/local_test.go @@ -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) diff --git a/source/memory/memory_test.go b/source/memory/memory_test.go index 6b82ee750..8cb3e92a7 100644 --- a/source/memory/memory_test.go +++ b/source/memory/memory_test.go @@ -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) diff --git a/source/network/network_test.go b/source/network/network_test.go index cae9884c3..e8aee0d59 100644 --- a/source/network/network_test.go +++ b/source/network/network_test.go @@ -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) diff --git a/source/pci/pci_test.go b/source/pci/pci_test.go index e419a4018..5adb84b50 100644 --- a/source/pci/pci_test.go +++ b/source/pci/pci_test.go @@ -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) diff --git a/source/storage/storage_test.go b/source/storage/storage_test.go index 8f501a892..835d9979a 100644 --- a/source/storage/storage_test.go +++ b/source/storage/storage_test.go @@ -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) diff --git a/source/system/system_test.go b/source/system/system_test.go index 58b0c1a1d..c2324057b 100644 --- a/source/system/system_test.go +++ b/source/system/system_test.go @@ -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) diff --git a/source/usb/usb_test.go b/source/usb/usb_test.go index 460402536..b0bdc594c 100644 --- a/source/usb/usb_test.go +++ b/source/usb/usb_test.go @@ -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)