Debian Codegraph @

internal/testutils/feature_test.go

raw symbols SCIP
1 package testutils
2
3 import (
4 "testing"
5
6 "github.com/go-quicktest/qt"
7 )
8
9 func TestIgnoreKernelVersionCheckWhenEnvVarIsSet(t *testing.T) {
10 tests := []struct {
11 name string
12 toIgnoreNamesEnvValue string
13 testName string
14 ignoreKernelVersionCheck bool
15 }{
16 {
17 name: "should NOT ignore kernel version check if environment var set to empty string",
18 toIgnoreNamesEnvValue: "",
19 testName: "TestABC",
20 ignoreKernelVersionCheck: false,
21 },
22 {
23 name: "should ignore kernel version check if environment var set to skip test name with single value",
24 toIgnoreNamesEnvValue: "TestABC",
25 testName: "TestABC",
26 ignoreKernelVersionCheck: true,
27 },
28 {
29 name: "should match test name when multiple comma separated names list is provided",
30 toIgnoreNamesEnvValue: "TestABC,TestXYZ",
31 testName: "TestXYZ",
32 ignoreKernelVersionCheck: true,
33 },
34 {
35 name: "should NOT match test name when multiple comma separated names list is provided but name is not present in list",
36 toIgnoreNamesEnvValue: "TestABC,TestXYZ",
37 testName: "TestPQR",
38 ignoreKernelVersionCheck: false,
39 },
40 {
41 name: "should match test name if names list has leading/trailing spaces",
42 toIgnoreNamesEnvValue: "TestABC, TestXYZ , TestPQR",
43 testName: "TestXYZ",
44 ignoreKernelVersionCheck: true,
45 },
46 }
47 for _, tt := range tests {
48 t.Run(tt.name, func(t *testing.T) {
49 t.Setenv(ignoreVersionEnvVar, tt.toIgnoreNamesEnvValue)
50
51 if got := ignoreVersionCheck(tt.testName); got != tt.ignoreKernelVersionCheck {
52 t.Errorf("ignoreKernelVersionCheck() = %v, want %v", got, tt.ignoreKernelVersionCheck)
53 }
54 })
55 }
56 }
57
58 func TestPlatformVersion(t *testing.T) {
59 qt.Assert(t, qt.IsFalse(platformVersion(t).Unspecified()))
60 }