MCPcopy Create free account
hub / github.com/AdRoll/baker / prepareUploadS3TestFolder

Function prepareUploadS3TestFolder

upload/s3_test.go:90–109  ·  view source on GitHub ↗

prepareUploadS3TestFolder creates a temp forlder and the selected number of files in it

(t *testing.T, numFiles int)

Source from the content-addressed store, hash-verified

88
89// prepareUploadS3TestFolder creates a temp forlder and the selected number of files in it
90func prepareUploadS3TestFolder(t *testing.T, numFiles int) (string, []string) {
91 t.Helper()
92
93 // Create a folder to store files to be uploaded
94 srcDir := t.TempDir()
95
96 // Write a bunch of files
97 var fnames []string
98 for i := 0; i < numFiles; i++ {
99 fname := filepath.Join(srcDir, fmt.Sprintf("test_file_%d", i))
100
101 if err := os.WriteFile(fname, []byte("abc"), 0644); err != nil {
102 t.Fatalf("can't create temp file: %v", err)
103 }
104
105 fnames = append(fnames, fname)
106 }
107
108 return srcDir, fnames
109}
110
111func TestS3Upload(t *testing.T) {
112 // Through the use of a mocked S3 service, this test verifies that sending

Callers 5

TestS3UploadFunction · 0.85
TestS3_uploadDirectoryFunction · 0.85
TestS3RunExitOnErrorFunction · 0.85
TestS3RunNotExitOnErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected