File: remove-tests-with-testdata.patch

package info (click to toggle)
golang-github-hashicorp-go-slug 0.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 224 kB
  • sloc: makefile: 5
file content (356 lines) | stat: -rw-r--r-- 8,345 bytes parent folder | download
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
Index: golang-github-hashicorp-go-slug/slug_test.go
===================================================================
--- golang-github-hashicorp-go-slug.orig/slug_test.go	2023-02-05 11:43:28.699878054 +0100
+++ golang-github-hashicorp-go-slug/slug_test.go	2023-02-05 11:46:12.815921418 +0100
@@ -15,203 +15,6 @@
 	"testing"
 )
 
-func TestPack(t *testing.T) {
-	slug := bytes.NewBuffer(nil)
-
-	meta, err := Pack("testdata/archive-dir", slug, true)
-	if err != nil {
-		t.Fatalf("err: %v", err)
-	}
-
-	gzipR, err := gzip.NewReader(slug)
-	if err != nil {
-		t.Fatalf("err: %v", err)
-	}
-
-	tarR := tar.NewReader(gzipR)
-	var (
-		symFound bool
-		fileList []string
-		slugSize int64
-	)
-
-	for {
-		hdr, err := tarR.Next()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			t.Fatalf("err: %v", err)
-		}
-
-		fileList = append(fileList, hdr.Name)
-		if hdr.Typeflag == tar.TypeReg || hdr.Typeflag == tar.TypeRegA {
-			slugSize += hdr.Size
-		}
-
-		if hdr.Name == "sub/bar.txt" {
-			if hdr.Typeflag != tar.TypeSymlink {
-				t.Fatalf("expect symlink for file 'sub/bar.txt'")
-			}
-			if hdr.Linkname != "../bar.txt" {
-				t.Fatalf("expect target of '../bar.txt', got %q", hdr.Linkname)
-			}
-			symFound = true
-		}
-	}
-
-	// Make sure we saw and handled a symlink
-	if !symFound {
-		t.Fatal("expected to find symlink")
-	}
-
-	// Make sure the .git directory is ignored
-	for _, file := range fileList {
-		if strings.Contains(file, ".git") {
-			t.Fatalf("unexpected .git content: %s", file)
-		}
-	}
-
-	// Make sure the .terraform directory is ignored,
-	// except for the .terraform/modules subdirectory.
-	for _, file := range fileList {
-		if strings.HasPrefix(file, ".terraform"+string(filepath.Separator)) &&
-			!strings.HasPrefix(file, filepath.Clean(".terraform/modules")) {
-			t.Fatalf("unexpected .terraform content: %s", file)
-		}
-	}
-
-	// Make sure .terraform/modules is included.
-	moduleDir := false
-	for _, file := range fileList {
-		if strings.HasPrefix(file, filepath.Clean(".terraform/modules")) {
-			moduleDir = true
-			break
-		}
-	}
-	if !moduleDir {
-		t.Fatal("expected to include .terraform/modules")
-	}
-
-	// Make sure .terraformrc is included.
-	terraformrc := false
-	for _, file := range fileList {
-		if file == ".terraformrc" {
-			terraformrc = true
-			break
-		}
-	}
-	if !terraformrc {
-		t.Fatal("expected to include .terraformrc")
-	}
-
-	// Make sure foo.terraform/bar.txt is included.
-	fooTerraformDir := false
-	for _, file := range fileList {
-		if file == filepath.Clean("foo.terraform/bar.txt") {
-			fooTerraformDir = true
-			break
-		}
-	}
-	if !fooTerraformDir {
-		t.Fatal("expected to include foo.terraform/bar.txt")
-	}
-
-	// Make sure baz.txt is excluded.
-	bazTxt := false
-	for _, file := range fileList {
-		if file == filepath.Clean("baz.txt") {
-			bazTxt = true
-			break
-		}
-	}
-	if bazTxt {
-		t.Fatal("should not include baz.txt")
-	}
-
-	// Check the metadata
-	expect := &Meta{
-		Files: fileList,
-		Size:  slugSize,
-	}
-	if !reflect.DeepEqual(meta, expect) {
-		t.Fatalf("\nexpect:\n%#v\n\nactual:\n%#v", expect, meta)
-	}
-}
-
-func TestPackWithoutIgnoring(t *testing.T) {
-	slug := bytes.NewBuffer(nil)
-
-	// By default NewPacker() creates a Packer that does not use
-	// .terraformignore or dereference symlinks.
-	p, err := NewPacker()
-	if err != nil {
-		t.Fatalf("err: %v", err)
-	}
-
-	meta, err := p.Pack("testdata/archive-dir", slug)
-	if err != nil {
-		t.Fatalf("err: %v", err)
-	}
-
-	gzipR, err := gzip.NewReader(slug)
-	if err != nil {
-		t.Fatalf("err: %v", err)
-	}
-
-	tarR := tar.NewReader(gzipR)
-	var (
-		fileList []string
-		slugSize int64
-	)
-
-	for {
-		hdr, err := tarR.Next()
-		if err == io.EOF {
-			break
-		}
-		if err != nil {
-			t.Fatalf("err: %v", err)
-		}
-
-		fileList = append(fileList, hdr.Name)
-		if hdr.Typeflag == tar.TypeReg || hdr.Typeflag == tar.TypeRegA {
-			slugSize += hdr.Size
-		}
-	}
-
-	// baz.txt would normally be ignored, but should not be
-	var bazFound bool
-	for _, file := range fileList {
-		if file == "baz.txt" {
-			bazFound = true
-		}
-	}
-	if !bazFound {
-		t.Fatal("expected file baz.txt to be present, but not found")
-	}
-
-	// .terraform/file.txt would normally be ignored, but should not be
-	var dotTerraformFileFound bool
-	for _, file := range fileList {
-		if file == ".terraform/file.txt" {
-			dotTerraformFileFound = true
-		}
-	}
-	if !dotTerraformFileFound {
-		t.Fatal("expected file .terraform/file.txt to be present, but not found")
-	}
-
-	// Check the metadata
-	expect := &Meta{
-		Files: fileList,
-		Size:  slugSize,
-	}
-	if !reflect.DeepEqual(meta, expect) {
-		t.Fatalf("\nexpect:\n%#v\n\nactual:\n%#v", expect, meta)
-	}
-}
-
 func TestPack_symlinks(t *testing.T) {
 	type tcase struct {
 		absolute     bool
@@ -361,38 +164,6 @@
 	}
 }
 
-func TestUnpack(t *testing.T) {
-	// First create the slug file so we can try to unpack it.
-	slug := bytes.NewBuffer(nil)
-
-	if _, err := Pack("testdata/archive-dir", slug, true); err != nil {
-		t.Fatalf("err: %v", err)
-	}
-
-	// Create a dir to unpack into.
-	dst, err := ioutil.TempDir("", "slug")
-	if err != nil {
-		t.Fatalf("err: %v", err)
-	}
-	defer os.RemoveAll(dst)
-
-	// Now try unpacking it.
-	if err := Unpack(slug, dst); err != nil {
-		t.Fatalf("err: %v", err)
-	}
-
-	// Verify all the files
-	verifyFile(t, filepath.Join(dst, "bar.txt"), 0, "bar\n")
-	verifyFile(t, filepath.Join(dst, "sub", "bar.txt"), os.ModeSymlink, "../bar.txt")
-	verifyFile(t, filepath.Join(dst, "sub", "zip.txt"), 0, "zip\n")
-
-	// Check that we can set permissions properly
-	verifyPerms(t, filepath.Join(dst, "bar.txt"), 0644)
-	verifyPerms(t, filepath.Join(dst, "sub", "zip.txt"), 0644)
-	verifyPerms(t, filepath.Join(dst, "sub", "bar.txt"), 0644)
-	verifyPerms(t, filepath.Join(dst, "exe"), 0755)
-}
-
 func TestUnpackDuplicateNoWritePerm(t *testing.T) {
 	dir, err := ioutil.TempDir("", "slug")
 	if err != nil {
Index: golang-github-hashicorp-go-slug/terraformignore_test.go
===================================================================
--- golang-github-hashicorp-go-slug.orig/terraformignore_test.go	2023-02-05 11:43:28.699878054 +0100
+++ golang-github-hashicorp-go-slug/terraformignore_test.go	2023-02-05 11:46:33.927926898 +0100
@@ -11,104 +11,4 @@
 		t.Fatal("A directory without .terraformignore should get the default patterns")
 	}
 
-	// load the .terraformignore file's patterns
-	ignoreRules := parseIgnoreFile("testdata/archive-dir")
-	type file struct {
-		// the actual path, should be file path format /dir/subdir/file.extension
-		path string
-		// should match
-		match bool
-	}
-	paths := []file{
-		{
-			path:  ".terraform/",
-			match: true,
-		},
-		{
-			path:  "included.txt",
-			match: false,
-		},
-		{
-			path:  ".terraform/foo/bar",
-			match: true,
-		},
-		{
-			path:  ".terraform/foo/bar/more/directories/so/many",
-			match: true,
-		},
-		{
-			path:  ".terraform/foo/ignored-subdirectory/",
-			match: true,
-		},
-		{
-			path:  "baz.txt",
-			match: true,
-		},
-		{
-			path:  "parent/foo/baz.txt",
-			match: true,
-		},
-		{
-			path:  "parent/foo/bar.tf",
-			match: true,
-		},
-		{
-			path:  "parent/bar/bar.tf",
-			match: false,
-		},
-		// baz.txt is ignored, but a file name including it should not be
-		{
-			path:  "something/with-baz.txt",
-			match: false,
-		},
-		{
-			path:  "something/baz.x",
-			match: false,
-		},
-		// Getting into * patterns
-		{
-			path:  "foo/ignored-doc.md",
-			match: true,
-		},
-		// Should match [a-z] group
-		{
-			path:  "bar/something-a.txt",
-			match: true,
-		},
-		// ignore sub- terraform.d paths
-		{
-			path:  "some-module/terraform.d/x",
-			match: true,
-		},
-		// but not the root one
-		{
-			path:  "terraform.d/",
-			match: false,
-		},
-		{
-			path:  "terraform.d/foo",
-			match: false,
-		},
-		// We ignore the directory, but a file of the same name could exist
-		{
-			path:  "terraform.d",
-			match: false,
-		},
-		// boop.text is ignored everywhere
-		{
-			path:  "baz/boop.txt",
-			match: true,
-		},
-		// except at current directory
-		{
-			path:  "boop.txt",
-			match: false,
-		},
-	}
-	for i, p := range paths {
-		match := matchIgnoreRule(p.path, ignoreRules)
-		if match != p.match {
-			t.Fatalf("%s at index %d should be %t", p.path, i, p.match)
-		}
-	}
 }