Tests: Add tests for internal/config

This commit is contained in:
theresa 2021-08-24 19:09:09 +02:00
parent 73df6d68ec
commit b707f1cb0c
2 changed files with 49 additions and 9 deletions

View file

@ -14,6 +14,14 @@ func TestConfig_FFmpegEncoder(t *testing.T) {
assert.Equal(t, "testEncoder", c.FFmpegEncoder())
}
func TestConfig_FFmpegEnabled(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, true, c.FFmpegEnabled())
c.options.DisableFFmpeg = true
assert.Equal(t, false, c.FFmpegEnabled())
}
func TestConfig_FFmpegBuffers(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, 8, c.FFmpegBuffers())

View file

@ -104,17 +104,49 @@ func TestConfig_OriginalsAlbumsPath(t *testing.T) {
}
func TestConfig_CreateDirectories(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
t.Run("no error", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{
options: NewTestOptions(),
token: rnd.Token(8),
}
c := &Config{
options: NewTestOptions(),
token: rnd.Token(8),
}
if err := c.CreateDirectories(); err != nil {
t.Fatal(err)
}
if err := c.CreateDirectories(); err != nil {
t.Fatal(err)
}
})
}
func TestConfig_CreateDirectories2(t *testing.T) {
t.Run("asset path not found", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{
options: NewTestOptions(),
token: rnd.Token(8),
}
c.options.AssetsPath = ""
err := c.CreateDirectories()
assert.Contains(t, err.Error(), "assets path not found")
})
t.Run("asset path not found", func(t *testing.T) {
testConfigMutex.Lock()
defer testConfigMutex.Unlock()
c := &Config{
options: NewTestOptions(),
token: rnd.Token(8),
}
t.Log(c.options.OriginalsPath)
c.options.OriginalsPath = ""
t.Log(c.options.OriginalsPath)
err := c.CreateDirectories()
t.Log(err)
assert.Contains(t, err.Error(), "originals path not found")
})
}
func TestConfig_ConfigFile2(t *testing.T) {