2024-05-04 22:01:57 +02:00
|
|
|
package conf_test
|
2020-03-17 12:30:59 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2021-12-19 20:43:33 +01:00
|
|
|
"path/filepath"
|
2020-03-17 12:30:59 +01:00
|
|
|
"testing"
|
|
|
|
|
2024-02-29 01:09:55 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
2024-05-04 22:01:57 +02:00
|
|
|
|
2025-01-14 01:06:47 +01:00
|
|
|
"code.bcarlin.net/go/conf"
|
2020-03-17 12:30:59 +01:00
|
|
|
)
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
func TestJSONFiles(t *testing.T) {
|
|
|
|
t.Parallel()
|
2020-03-17 12:30:59 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
runTestSuite(t, "json")
|
2020-03-17 12:30:59 +01:00
|
|
|
}
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
func TestTOMLFiles(t *testing.T) {
|
2024-02-29 01:09:55 +01:00
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
runTestSuite(t, "toml")
|
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
func TestUnknownFiles(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("LoadFile", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
s := struct{}{}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.LoadFile("test_data/valid.unknown", &s)
|
|
|
|
if assert.Error(t, err) {
|
|
|
|
assert.ErrorIs(t, err, conf.ErrUnsupportedFileType)
|
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
})
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("SaveFile", func(t *testing.T) {
|
2024-02-29 01:09:55 +01:00
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
s := struct{}{}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.SaveFile("test.unknown", &s)
|
|
|
|
if assert.Error(t, err) {
|
|
|
|
assert.ErrorIs(t, err, conf.ErrUnsupportedFileType)
|
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.NoFileExists(t, "test.unknown")
|
2024-02-29 01:09:55 +01:00
|
|
|
})
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("LoadAndUpdateFile", func(t *testing.T) {
|
2024-02-29 01:09:55 +01:00
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
s := struct{}{}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.LoadAndUpdateFile("test.unknown", &s)
|
|
|
|
if assert.Error(t, err) {
|
|
|
|
assert.ErrorIs(t, err, conf.ErrUnsupportedFileType)
|
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.NoFileExists(t, "test.unknown")
|
2020-03-17 12:30:59 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
func runTestSuite(t *testing.T, ext string) {
|
|
|
|
t.Helper()
|
2021-12-19 20:43:33 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
testLoadFile(t, ext)
|
|
|
|
testLoadFiles(t, ext)
|
|
|
|
testSaveFile(t, ext)
|
|
|
|
testLoadAndUpdateFile(t, ext)
|
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
type testconf struct {
|
|
|
|
inUpdate func()
|
|
|
|
String string
|
|
|
|
Invariant string
|
|
|
|
Int int
|
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
func (t testconf) Update() {
|
|
|
|
if t.inUpdate != nil {
|
|
|
|
t.inUpdate()
|
|
|
|
}
|
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
func testLoadFile(t *testing.T, ext string) {
|
|
|
|
t.Helper()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("LoadFile", func(t *testing.T) {
|
2024-02-29 01:09:55 +01:00
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("with a valid file", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Int: 1,
|
|
|
|
Invariant: "should not change",
|
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
file := "test_data/valid." + ext
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.LoadFile(file, &c)
|
|
|
|
require.NoError(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.Equal(t, "config string", c.String)
|
|
|
|
assert.Equal(t, 42, c.Int)
|
|
|
|
assert.Equal(t, "should not change", c.Invariant)
|
|
|
|
})
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("with an invalid file", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Int: 1,
|
|
|
|
Invariant: "should not change",
|
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
file := "test_data/invalid." + ext
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.LoadFile(file, &c)
|
|
|
|
require.Error(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.Equal(t, "default string", c.String)
|
|
|
|
assert.Equal(t, 1, c.Int)
|
|
|
|
assert.Equal(t, "should not change", c.Invariant)
|
|
|
|
})
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("with a non existent file", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Int: 1,
|
|
|
|
Invariant: "should not change",
|
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
file := "does-not-exist." + ext
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.LoadFile(file, &c)
|
|
|
|
require.Error(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.Equal(t, "default string", c.String)
|
|
|
|
assert.Equal(t, 1, c.Int)
|
|
|
|
assert.Equal(t, "should not change", c.Invariant)
|
|
|
|
})
|
2021-12-19 20:43:33 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
func testLoadFiles(t *testing.T, ext string) {
|
|
|
|
t.Helper()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("LoadFiles", func(t *testing.T) {
|
2024-02-29 01:09:55 +01:00
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("with two valid files with different options", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
c := testconf{}
|
|
|
|
err := conf.LoadFiles(&c, "test_data/part1."+ext, "test_data/part2."+ext)
|
|
|
|
require.NoError(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.Equal(t, "foo", c.String)
|
|
|
|
assert.Equal(t, 42, c.Int)
|
|
|
|
})
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("with two valid files with the same option", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
c := testconf{}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.LoadFiles(&c, "test_data/same1."+ext, "test_data/same2."+ext)
|
|
|
|
require.NoError(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.Equal(t, "bar", c.String)
|
|
|
|
})
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("with one non-existing and one existing file", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2020-03-17 12:30:59 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
c := testconf{}
|
2020-03-17 12:30:59 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.LoadFiles(&c, "does-not-exist."+ext, "test_data/valid."+ext)
|
|
|
|
require.NoError(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.Equal(t, "config string", c.String)
|
|
|
|
})
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("with one invalid and one valid file", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
c := testconf{}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.LoadFiles(&c, "test_data/invalid."+ext, "test_data/valid."+ext)
|
|
|
|
require.Error(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.Equal(t, "", c.String)
|
|
|
|
})
|
2024-02-29 01:09:55 +01:00
|
|
|
})
|
2024-05-06 11:19:26 +02:00
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
func testSaveFile(t *testing.T, ext string) {
|
|
|
|
t.Helper()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("SaveFile", func(t *testing.T) {
|
2024-02-29 01:09:55 +01:00
|
|
|
t.Parallel()
|
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("with a valid path", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Invariant: "should not change",
|
|
|
|
Int: 1,
|
|
|
|
}
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
file := filepath.Join(tmpDir, "test."+ext)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.SaveFile(file, &c)
|
|
|
|
require.NoError(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
require.FileExists(t, file)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
expected, err := os.ReadFile("test_data/full." + ext)
|
|
|
|
require.NoError(t, err)
|
|
|
|
got, err := os.ReadFile(file)
|
|
|
|
require.NoError(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.Equal(t, string(expected), string(got))
|
|
|
|
})
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("with a valid path and invalid data", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
tmpDir := t.TempDir()
|
|
|
|
file := filepath.Join(tmpDir, "test."+ext)
|
2020-03-17 12:30:59 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.SaveFile(file, func() error { return nil })
|
|
|
|
require.Error(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.NoFileExists(t, file)
|
|
|
|
})
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("with an invalid path", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Invariant: "should not change",
|
|
|
|
Int: 1,
|
|
|
|
}
|
|
|
|
file := "cannot/write/here." + ext
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
err := conf.SaveFile(file, &c)
|
|
|
|
require.Error(t, err)
|
2024-05-04 22:01:57 +02:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.NoFileExists(t, file)
|
|
|
|
})
|
2024-02-29 01:09:55 +01:00
|
|
|
})
|
2024-05-06 11:19:26 +02:00
|
|
|
}
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
func testLoadAndUpdateFile(t *testing.T, ext string) {
|
|
|
|
t.Helper()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("LoadAndUpdateFile", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
t.Run("when the target file does not exist", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
updated := false
|
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Int: 1,
|
|
|
|
Invariant: "should not change",
|
|
|
|
inUpdate: func() { updated = true },
|
|
|
|
}
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
file := filepath.Join(tmpDir, "does-not-exist."+ext)
|
|
|
|
|
|
|
|
err := conf.LoadAndUpdateFile(file, &c)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
require.FileExists(t, file)
|
|
|
|
|
|
|
|
var c2 testconf
|
|
|
|
err = conf.LoadFile(file, &c2)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, c.String, c2.String)
|
|
|
|
assert.Equal(t, c.Int, c2.Int)
|
|
|
|
assert.Equal(t, c.Invariant, c2.Invariant)
|
|
|
|
|
|
|
|
assert.False(t, updated)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when the path cannot be written", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
updated := false
|
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Int: 1,
|
|
|
|
Invariant: "should not change",
|
|
|
|
inUpdate: func() { updated = true },
|
|
|
|
}
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
file := filepath.Join(tmpDir, "does-not-exist", "test."+ext)
|
|
|
|
|
|
|
|
err := conf.LoadAndUpdateFile(file, &c)
|
|
|
|
require.Error(t, err)
|
|
|
|
|
|
|
|
assert.NoFileExists(t, file)
|
|
|
|
|
|
|
|
assert.False(t, updated)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when the config file is invalid", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
updated := false
|
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Int: 1,
|
|
|
|
Invariant: "should not change",
|
|
|
|
inUpdate: func() { updated = true },
|
|
|
|
}
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
file := filepath.Join(tmpDir, "test."+ext)
|
|
|
|
|
|
|
|
content, err := os.ReadFile("test_data/invalid." + ext)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = os.WriteFile(file, content, 0o600)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = conf.LoadAndUpdateFile("test_data/invalid."+ext, &c)
|
|
|
|
require.Error(t, err)
|
|
|
|
|
|
|
|
assert.False(t, updated)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when the config file is valid", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
updated := false
|
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Int: 1,
|
|
|
|
Invariant: "should not change",
|
|
|
|
inUpdate: func() { updated = true },
|
|
|
|
}
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
file := filepath.Join(tmpDir, "test."+ext)
|
|
|
|
|
|
|
|
content, err := os.ReadFile("test_data/valid." + ext)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = os.WriteFile(file, content, 0o600)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = conf.LoadAndUpdateFile(file, &c)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
var c2 testconf
|
|
|
|
err = conf.LoadFile(file, &c2)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.Equal(t, "config string", c2.String)
|
|
|
|
assert.Equal(t, 42, c2.Int)
|
|
|
|
assert.Equal(t, "should not change", c2.Invariant)
|
|
|
|
|
|
|
|
assert.True(t, updated)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when the config file is missing options", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
|
|
|
|
updated := false
|
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Int: 1,
|
|
|
|
Invariant: "should not change",
|
|
|
|
inUpdate: func() { updated = true },
|
|
|
|
}
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
file := filepath.Join(tmpDir, "test."+ext)
|
|
|
|
|
|
|
|
content, err := os.ReadFile("test_data/valid." + ext)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = os.WriteFile(file, content, 0o600)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = conf.LoadAndUpdateFile(file, &c)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
newContent, err := os.ReadFile(file)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
assert.Contains(t, string(newContent), "Invariant")
|
|
|
|
|
|
|
|
assert.True(t, updated)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("when the config contains unknown options", func(t *testing.T) {
|
|
|
|
t.Parallel()
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
updated := false
|
|
|
|
c := testconf{
|
|
|
|
String: "default string",
|
|
|
|
Int: 1,
|
|
|
|
Invariant: "should not change",
|
|
|
|
inUpdate: func() { updated = true },
|
|
|
|
}
|
|
|
|
tmpDir := t.TempDir()
|
|
|
|
file := filepath.Join(tmpDir, "test."+ext)
|
|
|
|
|
|
|
|
content, err := os.ReadFile("test_data/unknown." + ext)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = os.WriteFile(file, content, 0o600)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
err = conf.LoadAndUpdateFile(file, &c)
|
|
|
|
require.NoError(t, err)
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
newContent, err := os.ReadFile(file)
|
|
|
|
require.NoError(t, err)
|
|
|
|
assert.NotContains(t, string(newContent), "Unknown")
|
2024-02-29 01:09:55 +01:00
|
|
|
|
2024-05-06 11:19:26 +02:00
|
|
|
assert.True(t, updated)
|
|
|
|
})
|
2020-03-17 12:30:59 +01:00
|
|
|
})
|
|
|
|
}
|