mirror of
https://github.com/containers/buildah.git
synced 2025-04-18 07:04:05 +03:00
unit_test: use Parallel test where possible
Add `t.Parallel()` to unit tests whereever its possible without race. Signed-off-by: flouthoc <flouthoc.git@gmail.com>
This commit is contained in:
parent
ae5e123314
commit
aadfc5cf30
@ -40,6 +40,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
func TestOpenBuilderCommonBuildOpts(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.TODO()
|
||||
store, err := storage.GetStore(types.StoreOptions{
|
||||
RunRoot: t.TempDir(),
|
||||
|
@ -123,6 +123,7 @@ func testMinimal(t *testing.T, modify func(g *generate.Generator, rootDir, bundl
|
||||
}
|
||||
|
||||
func TestNoop(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -130,6 +131,7 @@ func TestNoop(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMinimalSkeleton(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -142,6 +144,7 @@ func TestMinimalSkeleton(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessTerminal(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -160,6 +163,7 @@ func TestProcessTerminal(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessConsoleSize(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -182,6 +186,7 @@ func TestProcessConsoleSize(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessUser(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -205,6 +210,7 @@ func TestProcessUser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessEnv(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -226,6 +232,7 @@ func TestProcessEnv(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessCwd(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -245,6 +252,7 @@ func TestProcessCwd(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessCapabilities(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -289,6 +297,7 @@ func TestProcessCapabilities(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessRlimits(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -327,6 +336,7 @@ func TestProcessRlimits(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessNoNewPrivileges(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -348,6 +358,7 @@ func TestProcessNoNewPrivileges(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestProcessOOMScoreAdj(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -370,6 +381,7 @@ func TestProcessOOMScoreAdj(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHostname(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -387,6 +399,7 @@ func TestHostname(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMounts(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -547,6 +560,7 @@ func TestMounts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLinuxIDMapping(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
@ -584,6 +598,7 @@ func TestLinuxIDMapping(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLinuxIDMappingShift(t *testing.T) {
|
||||
t.Parallel()
|
||||
if unix.Getuid() != 0 {
|
||||
t.Skip("tests need to be run as root")
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSizeFormatting(t *testing.T) {
|
||||
t.Parallel()
|
||||
size := formattedSize(0)
|
||||
if size != "0 B" {
|
||||
t.Errorf("Error formatting size: expected '%s' got '%s'", "0 B", size)
|
||||
@ -22,6 +23,7 @@ func TestSizeFormatting(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMatchWithTag(t *testing.T) {
|
||||
t.Parallel()
|
||||
isMatch := matchesReference("gcr.io/pause:latest", "pause:latest")
|
||||
if !isMatch {
|
||||
t.Error("expected match, got not match")
|
||||
@ -34,6 +36,7 @@ func TestMatchWithTag(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNoMatchesReferenceWithTag(t *testing.T) {
|
||||
t.Parallel()
|
||||
isMatch := matchesReference("gcr.io/pause:latest", "redis:latest")
|
||||
if isMatch {
|
||||
t.Error("expected no match, got match")
|
||||
@ -46,6 +49,7 @@ func TestNoMatchesReferenceWithTag(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMatchesReferenceWithoutTag(t *testing.T) {
|
||||
t.Parallel()
|
||||
isMatch := matchesReference("gcr.io/pause:latest", "pause")
|
||||
if !isMatch {
|
||||
t.Error("expected match, got not match")
|
||||
@ -58,6 +62,7 @@ func TestMatchesReferenceWithoutTag(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNoMatchesReferenceWithoutTag(t *testing.T) {
|
||||
t.Parallel()
|
||||
isMatch := matchesReference("gcr.io/pause:latest", "redis")
|
||||
if isMatch {
|
||||
t.Error("expected no match, got match")
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCommitLinkedLayers(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.TODO()
|
||||
now := time.Now()
|
||||
|
||||
|
@ -41,6 +41,7 @@ func (ts *testRetryCopyImageWrappedStore) CreateImage(id string, names []string,
|
||||
}
|
||||
|
||||
func TestRetryCopyImage(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.TODO()
|
||||
|
||||
graphDriverName := os.Getenv("STORAGE_DRIVER")
|
||||
|
@ -66,6 +66,7 @@ func (d *dummyAttestationHandler) ServeHTTP(rw http.ResponseWriter, req *http.Re
|
||||
}
|
||||
|
||||
func TestCWConvertImage(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := context.TODO()
|
||||
for _, status := range []int{http.StatusOK, http.StatusInternalServerError} {
|
||||
for _, ignoreChainRetrievalErrors := range []bool{false, true} {
|
||||
|
@ -17,6 +17,7 @@ func init() {
|
||||
}
|
||||
|
||||
func TestXattrs(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !xattrsSupported {
|
||||
t.Skipf("xattrs are not supported on this platform, skipping")
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPullPolicy(t *testing.T) {
|
||||
t.Parallel()
|
||||
for name, val := range PolicyMap {
|
||||
assert.Equal(t, name, val.String())
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestParseGitBuildContext(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Tests with only repo
|
||||
repo, subdir, branch := parseGitBuildContext("https://github.com/containers/repo.git")
|
||||
assert.Equal(t, repo, "https://github.com/containers/repo.git")
|
||||
|
@ -25,6 +25,7 @@ func (c *CompositeDigester) isOpen() bool {
|
||||
}
|
||||
|
||||
func TestCompositeDigester(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
itemTypes []string
|
||||
@ -186,6 +187,7 @@ func TestCompositeDigester(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTarFilterer(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
name string
|
||||
input, output map[string]string
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestHistoryEntriesEqual(t *testing.T) {
|
||||
t.Parallel()
|
||||
testCases := []struct {
|
||||
a, b string
|
||||
equal bool
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGeneratePathChecksum(t *testing.T) {
|
||||
t.Parallel()
|
||||
tempDir := t.TempDir()
|
||||
|
||||
tempFile, err := os.CreateTemp(tempDir, "testfile")
|
||||
|
@ -148,6 +148,7 @@ func checkValue(t *testing.T, value reflect.Value, name string, kind reflect.Kin
|
||||
}
|
||||
|
||||
func TestGoDockerclientConfigFromSchema2Config(t *testing.T) {
|
||||
t.Parallel()
|
||||
var input manifest.Schema2Config
|
||||
fillAllFields(t, &input)
|
||||
output := GoDockerclientConfigFromSchema2Config(&input)
|
||||
@ -157,6 +158,7 @@ func TestGoDockerclientConfigFromSchema2Config(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSchema2ConfigFromGoDockerclientConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
var input dockerclient.Config
|
||||
fillAllFields(t, &input)
|
||||
output := Schema2ConfigFromGoDockerclientConfig(&input)
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSlop(t *testing.T) {
|
||||
t.Parallel()
|
||||
testCases := []struct {
|
||||
input int64
|
||||
slop string
|
||||
@ -84,6 +85,7 @@ func (d *dummyAttestationHandler) ServeHTTP(rw http.ResponseWriter, req *http.Re
|
||||
}
|
||||
|
||||
func TestArchive(t *testing.T) {
|
||||
t.Parallel()
|
||||
ociConfig := &v1.Image{
|
||||
Config: v1.ImageConfig{
|
||||
User: "root",
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCheckLUKSPassphrase(t *testing.T) {
|
||||
t.Parallel()
|
||||
passphrase, err := GenerateDiskEncryptionPassphrase()
|
||||
require.NoError(t, err)
|
||||
secondPassphrase, err := GenerateDiskEncryptionPassphrase()
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestReadWriteWorkloadConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Create a temporary file to stand in for a disk image.
|
||||
temp := filepath.Join(t.TempDir(), "disk.img")
|
||||
f, err := os.OpenFile(temp, os.O_CREATE|os.O_RDWR, 0o600)
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestBindFdToPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
first := t.TempDir()
|
||||
sampleData := []byte("sample data")
|
||||
err := os.WriteFile(filepath.Join(first, "testfile"), sampleData, 0o600)
|
||||
|
@ -19,6 +19,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
func TestOpenInChroot(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmpdir := t.TempDir()
|
||||
firstContents := []byte{0, 1, 2, 3}
|
||||
secondContents := []byte{4, 5, 6, 7}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestEncodeJSON(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmp := t.TempDir()
|
||||
map1 := map[string]any{
|
||||
"string": "yeah",
|
||||
@ -56,6 +57,7 @@ func TestEncodeJSON(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDecodeJSON(t *testing.T) {
|
||||
t.Parallel()
|
||||
tmp := t.TempDir()
|
||||
var map1, map2, map3 map[string]any
|
||||
err := os.WriteFile(filepath.Join(tmp, "1.json"), []byte(`
|
||||
@ -93,6 +95,7 @@ func TestDecodeJSON(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetComponentNameVersionPurl(t *testing.T) {
|
||||
t.Parallel()
|
||||
input := map[string]any{
|
||||
"name": "alice",
|
||||
"version": "1.0",
|
||||
@ -123,6 +126,7 @@ func TestGetComponentNameVersionPurl(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetLicenseID(t *testing.T) {
|
||||
t.Parallel()
|
||||
input := map[string]any{
|
||||
"licenseId": "driver",
|
||||
}
|
||||
@ -132,6 +136,7 @@ func TestGetLicenseID(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetPackageNameVersionInfoPurl(t *testing.T) {
|
||||
t.Parallel()
|
||||
input := map[string]any{
|
||||
"name": "alice",
|
||||
"versionInfo": "1.0",
|
||||
@ -194,6 +199,7 @@ func TestGetPackageNameVersionInfoPurl(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMergeSlicesWithoutDuplicatesFixed(t *testing.T) {
|
||||
t.Parallel()
|
||||
base := map[string]any{
|
||||
"array": []any{
|
||||
map[string]any{"first": 1},
|
||||
@ -217,6 +223,7 @@ func TestMergeSlicesWithoutDuplicatesFixed(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMergeSlicesWithoutDuplicatesDynamic(t *testing.T) {
|
||||
t.Parallel()
|
||||
base := map[string]any{
|
||||
"array": []any{
|
||||
map[string]any{"first": 1},
|
||||
@ -246,6 +253,7 @@ func TestMergeSlicesWithoutDuplicatesDynamic(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMergeSlicesWithoutDuplicatesNoop(t *testing.T) {
|
||||
t.Parallel()
|
||||
base := map[string]any{
|
||||
"array": []any{
|
||||
map[string]any{"first": 1},
|
||||
@ -269,6 +277,7 @@ func TestMergeSlicesWithoutDuplicatesNoop(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMergeSlicesWithoutDuplicatesMissing(t *testing.T) {
|
||||
t.Parallel()
|
||||
base := map[string]any{
|
||||
"array": []any{
|
||||
map[string]any{"first": 1},
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestPreset(t *testing.T) {
|
||||
t.Parallel()
|
||||
for presetName, expectToFind := range map[string]bool{
|
||||
"": true,
|
||||
"syft": true,
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetTempDir(t *testing.T) {
|
||||
t.Parallel()
|
||||
// test default
|
||||
err := os.Unsetenv("TMPDIR")
|
||||
require.NoError(t, err)
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestBindFromChroot(t *testing.T) {
|
||||
t.Parallel()
|
||||
if os.Getuid() != 0 {
|
||||
t.Skip("not running as root, assuming we can't mount or chroot")
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetMount(t *testing.T) {
|
||||
t.Parallel()
|
||||
tempDir := t.TempDir()
|
||||
rootDir := t.TempDir()
|
||||
runDir := t.TempDir()
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestGetImageName(t *testing.T) {
|
||||
t.Parallel()
|
||||
tt := []struct {
|
||||
caseName string
|
||||
name string
|
||||
@ -30,6 +31,7 @@ func TestGetImageName(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNoBaseImageSpecifierIsScratch(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert.Equal(t, "scratch", imagebuilder.NoBaseImageSpecifier) // juuuuust in case
|
||||
assert.Equal(t, "scratch", BaseImageFakeName)
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ kmem:*:2:
|
||||
`
|
||||
|
||||
func TestParseStripComments(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test reading group file, ignoring comment lines
|
||||
rc := bufio.NewScanner(strings.NewReader(testGroupData))
|
||||
line, ok := scanWithoutComments(rc)
|
||||
@ -24,6 +25,7 @@ func TestParseStripComments(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseNextGroup(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Test parsing group file
|
||||
rc := bufio.NewScanner(strings.NewReader(testGroupData))
|
||||
expected := []lookupGroupEntry{
|
||||
|
@ -35,24 +35,28 @@ func testFlagCompletion(t *testing.T, flags pflag.FlagSet, flagCompletions compl
|
||||
}
|
||||
|
||||
func TestUserNsFlagsCompletion(t *testing.T) {
|
||||
t.Parallel()
|
||||
flags := GetUserNSFlags(&UserNSResults{})
|
||||
flagCompletions := GetUserNSFlagsCompletions()
|
||||
testFlagCompletion(t, flags, flagCompletions)
|
||||
}
|
||||
|
||||
func TestNameSpaceFlagsCompletion(t *testing.T) {
|
||||
t.Parallel()
|
||||
flags := GetNameSpaceFlags(&NameSpaceResults{})
|
||||
flagCompletions := GetNameSpaceFlagsCompletions()
|
||||
testFlagCompletion(t, flags, flagCompletions)
|
||||
}
|
||||
|
||||
func TestBudFlagsCompletion(t *testing.T) {
|
||||
t.Parallel()
|
||||
flags := GetBudFlags(&BudResults{})
|
||||
flagCompletions := GetBudFlagsCompletions()
|
||||
testFlagCompletion(t, flags, flagCompletions)
|
||||
}
|
||||
|
||||
func TestFromAndBudFlagsCompletions(t *testing.T) {
|
||||
t.Parallel()
|
||||
flags, err := GetFromAndBudFlags(&FromAndBudResults{}, &UserNSResults{}, &NameSpaceResults{})
|
||||
if err != nil {
|
||||
t.Error("Could load the from and build flags.")
|
||||
@ -62,6 +66,7 @@ func TestFromAndBudFlagsCompletions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLookupEnvVarReferences(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("EmptyInput", func(t *testing.T) {
|
||||
assert.Empty(t, LookupEnvVarReferences(nil, nil))
|
||||
assert.Empty(t, LookupEnvVarReferences([]string{}, nil))
|
||||
@ -114,6 +119,7 @@ func TestLookupEnvVarReferences(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDecryptConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Just a smoke test for the default path.
|
||||
res, err := DecryptConfig(nil)
|
||||
assert.NoError(t, err)
|
||||
@ -121,6 +127,7 @@ func TestDecryptConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestEncryptConfig(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Just a smoke test for the default path.
|
||||
cfg, layers, err := EncryptConfig(nil, nil)
|
||||
assert.NoError(t, err)
|
||||
@ -129,6 +136,7 @@ func TestEncryptConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetFormat(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := GetFormat("bogus")
|
||||
assert.NotNil(t, err)
|
||||
|
||||
|
@ -11,6 +11,7 @@ type ImageData struct {
|
||||
}
|
||||
|
||||
func TestSetJSONFormatEncoder(t *testing.T) {
|
||||
t.Parallel()
|
||||
tt := []struct {
|
||||
name string
|
||||
imageData *ImageData
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestParseVersion(t *testing.T) {
|
||||
t.Parallel()
|
||||
tt := []struct {
|
||||
version string
|
||||
shouldFail bool
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCommonBuildOptionsFromFlagSet(t *testing.T) {
|
||||
t.Parallel()
|
||||
fs := pflag.NewFlagSet("testme", pflag.PanicOnError)
|
||||
fs.String("memory", "1GB", "")
|
||||
fs.String("shm-size", "5TB", "")
|
||||
@ -29,6 +30,7 @@ func TestCommonBuildOptionsFromFlagSet(t *testing.T) {
|
||||
|
||||
// TestDeviceParser verifies the given device strings is parsed correctly
|
||||
func TestDeviceParser(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skip("Devices is only supported on Linux")
|
||||
}
|
||||
@ -76,6 +78,7 @@ func TestDeviceParser(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsValidDeviceMode(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skip("Devices is only supported on Linux")
|
||||
}
|
||||
@ -88,6 +91,7 @@ func TestIsValidDeviceMode(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeviceFromPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
if runtime.GOOS != "linux" {
|
||||
t.Skip("Devices is only supported on Linux")
|
||||
}
|
||||
@ -115,6 +119,7 @@ func TestDeviceFromPath(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIDMappingOptions(t *testing.T) {
|
||||
t.Parallel()
|
||||
fs := pflag.NewFlagSet("testme", pflag.PanicOnError)
|
||||
pfs := pflag.NewFlagSet("persist", pflag.PanicOnError)
|
||||
fs.String("userns-uid-map-user", "", "")
|
||||
@ -134,6 +139,7 @@ func TestIDMappingOptions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestIsolation(t *testing.T) {
|
||||
t.Parallel()
|
||||
def, err := defaultIsolation()
|
||||
if err != nil {
|
||||
assert.Error(t, err)
|
||||
@ -162,6 +168,7 @@ func TestIsolation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNamespaceOptions(t *testing.T) {
|
||||
t.Parallel()
|
||||
fs := pflag.NewFlagSet("testme", pflag.PanicOnError)
|
||||
fs.String("cgroupns", "", "")
|
||||
err := fs.Parse([]string{"--cgroupns", "private"})
|
||||
@ -176,6 +183,7 @@ func TestNamespaceOptions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParsePlatform(t *testing.T) {
|
||||
t.Parallel()
|
||||
os, arch, variant, err := Platform("a/b/c")
|
||||
assert.NoError(t, err)
|
||||
assert.NoError(t, err)
|
||||
@ -195,6 +203,7 @@ func TestParsePlatform(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParsePullPolicy(t *testing.T) {
|
||||
t.Parallel()
|
||||
testCases := map[string]bool{
|
||||
"missing": true,
|
||||
"ifmissing": true,
|
||||
@ -221,6 +230,7 @@ func TestParsePullPolicy(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSplitStringWithColonEscape(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
volume string
|
||||
expectedResult []string
|
||||
@ -237,6 +247,7 @@ func TestSplitStringWithColonEscape(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSystemContextFromFlagSet(t *testing.T) {
|
||||
t.Parallel()
|
||||
fs := pflag.NewFlagSet("testme", pflag.PanicOnError)
|
||||
fs.Bool("tls-verify", false, "")
|
||||
err := fs.Parse([]string{"--tls-verify", "false"})
|
||||
|
@ -33,6 +33,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
|
||||
func TestRusage(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !Supported() {
|
||||
t.Skip("not supported on this platform")
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ func testClient(path string) ([]*agent.Key, error) {
|
||||
}
|
||||
|
||||
func TestAgentServer(t *testing.T) {
|
||||
t.Parallel()
|
||||
src, err := testNewKeySource()
|
||||
require.NoError(t, err)
|
||||
ag, err := NewAgentServer(src)
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestParseUlimit(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := ParseUlimit("bogus")
|
||||
assert.NotNil(t, err)
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestDiscoverContainerfile(t *testing.T) {
|
||||
t.Parallel()
|
||||
_, err := DiscoverContainerfile("./bogus")
|
||||
assert.NotNil(t, err)
|
||||
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
)
|
||||
|
||||
func TestAddRlimits(t *testing.T) {
|
||||
t.Parallel()
|
||||
tt := []struct {
|
||||
name string
|
||||
ulimit []string
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMergeEnv(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := [][3][]string{
|
||||
{
|
||||
[]string{"A=B", "B=C", "C=D"},
|
||||
@ -44,6 +45,7 @@ func TestMergeEnv(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRuntime(t *testing.T) {
|
||||
t.Parallel()
|
||||
os.Setenv("CONTAINERS_CONF", "/dev/null")
|
||||
conf, _ := config.Default()
|
||||
defaultRuntime := conf.Engine.OCIRuntime
|
||||
@ -60,6 +62,7 @@ func TestRuntime(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMountsSort(t *testing.T) {
|
||||
t.Parallel()
|
||||
mounts1a := []specs.Mount{
|
||||
{
|
||||
Source: "/a/bb/c",
|
||||
|
Loading…
x
Reference in New Issue
Block a user