39 lines
822 B
Go
39 lines
822 B
Go
|
package utini
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
"opslag.de/schobers/ut/utio"
|
||
|
)
|
||
|
|
||
|
func AssertSaveString(t *testing.T, file *File) string {
|
||
|
lines, err := save(file)
|
||
|
assert.Nil(t, err)
|
||
|
s, _ := utio.EncodeToString(&utio.Liner{Lines: lines})
|
||
|
return s
|
||
|
}
|
||
|
|
||
|
func AssertSaveMapString(t *testing.T, v interface{}) string {
|
||
|
file, err := MapToFile(v)
|
||
|
assert.Nil(t, err)
|
||
|
return AssertSaveString(t, file)
|
||
|
}
|
||
|
|
||
|
func TestMapToFile(t *testing.T) {
|
||
|
file, err := MapToFile(&testData1Struct)
|
||
|
assert.Nil(t, err)
|
||
|
s := AssertSaveString(t, file)
|
||
|
|
||
|
assert.Equal(t, testData1IniFile, s)
|
||
|
}
|
||
|
|
||
|
// TestSaveDefaultValues tests that default values are NOT applied during saving.
|
||
|
func TestSaveDefaultValues(t *testing.T) {
|
||
|
s := AssertSaveMapString(t, &testDataDefault{})
|
||
|
|
||
|
assert.Equal(t, `integer = 0
|
||
|
string = ""
|
||
|
`, s)
|
||
|
}
|