golang-lib/web/file/createfs_test.go

63 lines
1.3 KiB
Go
Raw Permalink Normal View History

2021-07-30 18:01:45 +02:00
package file_test
import (
"testing"
2023-10-23 21:40:10 +02:00
fsfile "codeberg.org/genofire/golang-lib/file"
"codeberg.org/genofire/golang-lib/web/file"
2021-07-30 18:01:45 +02:00
"github.com/stretchr/testify/assert"
)
func TestCreateFSOK(t *testing.T) {
assert := assert.New(t)
config := file.FSInfo{}
err := fsfile.ReadTOML("testdata/createfs_fs.toml", &config)
assert.NoError(err)
fs, err := config.Create()
assert.NoError(err)
assert.NoError(fs.Check())
}
func TestCreateS3(t *testing.T) {
assert := assert.New(t)
config := file.FSInfo{}
err := fsfile.ReadTOML("testdata/createfs_s3.toml", &config)
assert.NoError(err)
fs, err := config.Create()
assert.NoError(err)
assert.NoError(fs.Check())
}
func TestCreateFSNotOK(t *testing.T) {
assert := assert.New(t)
config := file.FSInfo{}
err := fsfile.ReadTOML("testdata/createfs_fsnone.toml", &config)
assert.NoError(err)
_, err = config.Create()
assert.ErrorIs(err, file.ErrNoFSRoot)
}
func TestCreateFSNone(t *testing.T) {
assert := assert.New(t)
config := file.FSInfo{}
err := fsfile.ReadTOML("testdata/createfs_none.toml", &config)
// https://github.com/naoina/toml/pull/51
assert.Contains(err.Error(), file.ErrInvalidFSType.Error())
}
func TestCreateFSInvalid(t *testing.T) {
assert := assert.New(t)
config := file.FSInfo{}
_, err := config.Create()
assert.ErrorIs(err, file.ErrNoFSRoot)
}