MCPcopy
hub / github.com/flyteorg/flyte / TestUploadFile

Function TestUploadFile

flytecopilot/data/utils_test.go:55–81  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func TestUploadFile(t *testing.T) {
56 tmpFolderLocation := ""
57 tmpPrefix := "util_test"
58
59 tmpDir, err := os.MkdirTemp(tmpFolderLocation, tmpPrefix)
60 assert.NoError(t, err)
61 defer func() {
62 assert.NoError(t, os.RemoveAll(tmpDir))
63 }()
64
65 exist := path.Join(tmpDir, "exist-file")
66 data := []byte("data")
67 l := int64(len(data))
68 assert.NoError(t, os.WriteFile(exist, data, os.ModePerm)) // #nosec G306
69 nonExist := path.Join(tmpDir, "non-exist-file")
70
71 store, err := storage.NewDataStore(&storage.Config{Type: storage.TypeMemory}, promutils.NewTestScope())
72 assert.NoError(t, err)
73
74 ctx := context.TODO()
75 assert.NoError(t, UploadFileToStorage(ctx, exist, "exist", l, store))
76 m, err := store.Head(ctx, "exist")
77 assert.True(t, m.Exists())
78 assert.NoError(t, err)
79
80 assert.Error(t, UploadFileToStorage(ctx, nonExist, "nonExist", l, store))
81}
82
83func TestDownloadFromHttp(t *testing.T) {
84 loc := storage.DataReference("https://raw.githubusercontent.com/flyteorg/flyte/master/README.md")

Callers

nothing calls this directly

Calls 6

NewDataStoreFunction · 0.92
NewTestScopeFunction · 0.92
UploadFileToStorageFunction · 0.85
HeadMethod · 0.65
ExistsMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected