|
1 | 1 | package localfs_test |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "context" |
4 | 5 | "os" |
5 | 6 | "testing" |
6 | 7 |
|
@@ -51,3 +52,39 @@ func TestAll(t *testing.T) { |
51 | 52 | assert.NotEqual(t, nil, err) |
52 | 53 | assert.Equal(t, nil, store) |
53 | 54 | } |
| 55 | + |
| 56 | +func TestNewReaderDir(t *testing.T) { |
| 57 | + // When a dir is requested, serve the index.html file instead |
| 58 | + localFsConf := &cloudstorage.Config{ |
| 59 | + Type: localfs.StoreType, |
| 60 | + AuthMethod: localfs.AuthFileSystem, |
| 61 | + LocalFS: "/tmp/mockcloud", |
| 62 | + TmpDir: "/tmp/localcache", |
| 63 | + } |
| 64 | + store, err := cloudstorage.NewStore(localFsConf) |
| 65 | + testutils.MockFile(store, "test/index.html", "test") |
| 66 | + assert.Equal(t, nil, err) |
| 67 | + assert.Equal(t, nil, err) |
| 68 | + _, err = store.NewReader("test") |
| 69 | + assert.Equal(t, err, cloudstorage.ErrObjectNotFound) |
| 70 | + err = store.Delete(context.Background(), "test/index.html") |
| 71 | + assert.Equal(t, nil, err) |
| 72 | +} |
| 73 | + |
| 74 | +func TestGetDir(t *testing.T) { |
| 75 | + // When a dir is requested, serve the index.html file instead |
| 76 | + localFsConf := &cloudstorage.Config{ |
| 77 | + Type: localfs.StoreType, |
| 78 | + AuthMethod: localfs.AuthFileSystem, |
| 79 | + LocalFS: "/tmp/mockcloud", |
| 80 | + TmpDir: "/tmp/localcache", |
| 81 | + } |
| 82 | + store, err := cloudstorage.NewStore(localFsConf) |
| 83 | + testutils.MockFile(store, "test/index.html", "test") |
| 84 | + assert.Equal(t, nil, err) |
| 85 | + assert.Equal(t, nil, err) |
| 86 | + _, err = store.Get(context.Background(), "test") |
| 87 | + assert.Equal(t, err, cloudstorage.ErrObjectNotFound) |
| 88 | + err = store.Delete(context.Background(), "test/index.html") |
| 89 | + assert.Equal(t, nil, err) |
| 90 | +} |
0 commit comments