File: parser_test.go

package info (click to toggle)
golang-github-containers-storage 1.24.8%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,324 kB
  • sloc: sh: 812; ansic: 319; makefile: 175; awk: 12
file content (37 lines) | stat: -rw-r--r-- 837 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// +build !windows

package idtools

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestParseIDMap(t *testing.T) {
	type tests struct {
		mapSpec    []string
		mapSetting string
		fail       bool
	}
	testList := []tests{
		{[]string{"0:1:100000"}, "uid", false},
		{[]string{"0:1:100000", "5:200000:100"}, "gid", false},
		{[]string{"0:1:100000", "5:200000:x100"}, "gid", true},
		{[]string{"0:1:100000"}, "uid", false},
		{[]string{"0:1:1000000000000000"}, "uid", true},
		{[]string{"b0:1:100000"}, "uid", true},
		{[]string{"0:b1:100000"}, "uid", true},
		{[]string{"0:1:1000b00"}, "uid", true},
		{[]string{"0100000"}, "uid", true},
	}

	for _, test := range testList {
		_, err := ParseIDMap(test.mapSpec, test.mapSetting)
		if test.fail {
			require.Error(t, err)
		} else {
			require.NoError(t, err)
		}
	}
}