(t *testing.T)
| 53 | } |
| 54 | |
| 55 | func 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 | |
| 83 | func TestDownloadFromHttp(t *testing.T) { |
| 84 | loc := storage.DataReference("https://raw.githubusercontent.com/flyteorg/flyte/master/README.md") |
nothing calls this directly
no test coverage detected