Debian Codegraph @

validator_test.go

raw symbols SCIP
1 package fsutilscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/
2
3 import (
4 "fmtscip-go gomod github.com/golang/go/src go1.21 fmt/"
5 "osscip-go gomod github.com/golang/go/src go1.21 os/"
6 "path/filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/"
7 "stringsscip-go gomod github.com/golang/go/src go1.21 strings/"
8 "testingscip-go gomod github.com/golang/go/src go1.21 testing/"
9
10 "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/"
11 "github.com/tonistiigi/fsutil/typesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/"
12 )
13
14 func TestValidatorSimpleFilesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorSimpleFiles().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
15 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
16 "ADD foo file",
17 "ADD foo2 file",
18 }))
19 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err)
20 }
21
22 func TestValidatorFilesNotInOrderscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorFilesNotInOrder().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
23 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
24 "ADD foo file",
25 "ADD foo2 file",
26 "ADD bar file",
27 }))
28 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
29 }
30
31 func TestValidatorFilesNotInOrder2scip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorFilesNotInOrder2().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
32 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
33 "ADD foo file",
34 "ADD foo2 file",
35 "ADD foo2 file",
36 }))
37 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
38 }
39
40 func TestValidatorDirIsFilescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorDirIsFile().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
41 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
42 "ADD foo file",
43 "ADD foo2 file",
44 "ADD foo2 dir",
45 }))
46 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
47 }
48
49 func TestValidatorDirIsFile2scip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorDirIsFile2().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
50 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
51 "ADD foo file",
52 "ADD foo2 dir",
53 "ADD foo2 file",
54 }))
55 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
56 }
57
58 func TestValidatorNoParentDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorNoParentDir().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
59 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
60 "ADD bar file",
61 "ADD foo/baz file",
62 }))
63 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
64 }
65
66 func TestValidatorParentFilescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorParentFile().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
67 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
68 "ADD bar file",
69 "ADD bar/baz file",
70 }))
71 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
72 }
73
74 func TestValidatorParentFile2scip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorParentFile2().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
75 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
76 "ADD foo/bar file",
77 }))
78 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
79 }
80
81 func TestValidatorSimpleDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorSimpleDir().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
82 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
83 "ADD foo dir",
84 "ADD foo/bar file",
85 }))
86 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err)
87 }
88
89 func TestValidatorSimpleDir2scip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorSimpleDir2().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
90 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
91 "ADD foo dir",
92 "ADD foo/bar file",
93 "ADD foo/bay dir",
94 "ADD foo/bay/aa file",
95 "ADD foo/bay/ab dir",
96 "ADD foo/bay/abb dir",
97 "ADD foo/bay/abb/a dir",
98 "ADD foo/bay/ba file",
99 "ADD foo/baz file",
100 }))
101 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err)
102 }
103
104 func TestValidatorBackToParentscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorBackToParent().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
105 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
106 "ADD foo dir",
107 "ADD foo/bar file",
108 "ADD foo/bay dir",
109 "ADD foo/bay/aa file",
110 "ADD foo/bay/ab dir",
111 "ADD foo/bay/ba file",
112 "ADD foo/bay dir",
113 "ADD foo/baz file",
114 }))
115 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
116 }
117 func TestValidatorParentOrderscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorParentOrder().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
118 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
119 "ADD foo dir",
120 "ADD foo/bar file",
121 "ADD foo/bay dir",
122 "ADD foo/bay/aa file",
123 "ADD foo/bay/ab dir",
124 "ADD foo/bar file",
125 }))
126 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
127 }
128 func TestValidatorBigJumpscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorBigJump().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
129 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
130 "ADD foo dir",
131 "ADD foo/a dir",
132 "ADD foo/a/foo dir",
133 "ADD foo/a/b/foo dir",
134 "ADD foo/a/b/c/foo dir",
135 "ADD foo/a/b/c/d/foo dir",
136 "ADD zzz dir",
137 }))
138 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
139 }
140 func TestValidatorDotscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorDot().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
141 // dot is before / in naive sort
142 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
143 "ADD foo dir",
144 "ADD foo/a dir",
145 "ADD foo.2 dir",
146 }))
147 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/NoError().(t, err)
148 }
149
150 func TestValidatorDot2scip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorDot2().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
151 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
152 "ADD foo.a dir",
153 "ADD foo/a/a dir",
154 }))
155 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
156
157 err = checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
158 "ADD foo dir",
159 "ADD foo. dir",
160 "ADD foo dir",
161 }))
162 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
163 }
164
165 func TestValidatorSkipDirscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/TestValidatorSkipDir().(t *testingscip-go gomod github.com/golang/go/src go1.21 testing/.Tscip-go gomod github.com/golang/go/src go1.21 testing/T#) {
166 err := checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().([]string{
167 "ADD bar dir",
168 "ADD bar/foo/a dir",
169 }))
170 assertscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/.Errorscip-go gomod github.com/stretchr/testify v1.8.4 `github.com/stretchr/testify/assert`/Error().(t, err)
171 }
172
173 func checkValidscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/checkValid().(inp []*changescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#) error {
174 v := &Validatorscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Validator#{}
175 for _, c := range inp {
176 if err := v.HandleChangescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/Validator#HandleChange().(c.kindscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#kind., c.pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#path., c.fiscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#fi., nil); err != nil {
177 return err
178 }
179 }
180 return nil
181 }
182
183 type changescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change# struct {
184 kindscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#kind. ChangeKindscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/ChangeKind#
185 pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#path. string
186 fiscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#fi. osscip-go gomod github.com/golang/go/src go1.21 os/.FileInfoscip-go gomod github.com/golang/go/src go1.21 os/FileInfo#
187 datascip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#data. string
188 }
189
190 func changeStreamscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/changeStream().(dt []string) (changes []*changescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#) {
191 for _, s := range dt {
192 changes = append(changes, parseChangescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/parseChange().(s))
193 }
194 return
195 }
196
197 func parseChangescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/parseChange().(str string) *changescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change# {
198 f := stringsscip-go gomod github.com/golang/go/src go1.21 strings/.Fieldsscip-go gomod github.com/golang/go/src go1.21 strings/Fields().(str)
199 errStr := fmtscip-go gomod github.com/golang/go/src go1.21 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.21 fmt/Sprintf().("invalid change %q", str)
200 if len(f) < 3 {
201 panic(errStr)
202 }
203 c := &changescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#{}
204 switch f[0] {
205 case "ADD":
206 c.kindscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#kind. = ChangeKindAddscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/ChangeKindAdd.
207 case "CHG":
208 c.kindscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#kind. = ChangeKindModifyscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/ChangeKindModify.
209 case "DEL":
210 c.kindscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#kind. = ChangeKindDeletescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/ChangeKindDelete.
211 default:
212 panic(errStr)
213 }
214 c.pathscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#path. = filepathscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/.FromSlashscip-go gomod github.com/golang/go/src go1.21 `path/filepath`/FromSlash().(f[1])
215 st := &typesscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/.Statscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#{}
216 switch f[2] {
217 case "file":
218 if len(f) > 3 {
219 if f[3][0] == '>' {
220 st.Linknamescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Linkname. = f[3][1:]
221 } else {
222 c.datascip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#data. = f[3]
223 }
224 }
225 case "dir":
226 st.Modescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Mode. |= uint32(osscip-go gomod github.com/golang/go/src go1.21 os/.ModeDirscip-go gomod github.com/golang/go/src go1.21 os/ModeDir.)
227 case "socket":
228 st.Modescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Mode. |= uint32(osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSocketscip-go gomod github.com/golang/go/src go1.21 os/ModeSocket.)
229 case "symlink":
230 if len(f) < 4 {
231 panic(errStr)
232 }
233 st.Modescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Mode. |= uint32(osscip-go gomod github.com/golang/go/src go1.21 os/.ModeSymlinkscip-go gomod github.com/golang/go/src go1.21 os/ModeSymlink.)
234 st.Linknamescip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil/types`/Stat#Linkname. = f[3]
235 }
236 c.fiscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/change#fi. = &StatInfoscip-go gomod github.com/tonistiigi/fsutil . `github.com/tonistiigi/fsutil`/StatInfo#{st}
237 return c
238 }