-
Roshan Patil authored09a5ce6a
configmdl_test.go 1.44 KiB
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
package configmdl
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
type tomlConfig struct {
Title string
Name string
AdditionalField string
Version string
}
func TestInitConfig(t *testing.T) {
var config tomlConfig
InitConfig("../testingdata/testData/config/config.toml", &config)
assert.True(t, config.Name == "github.com/OneOfOne/xxhash", "this should not throw error")
}
func TestSaveConfig(t *testing.T) {
var config tomlConfig
InitConfig("../testingdata/testData/config/config.toml", &config)
err := SaveConfig("../testingdata/testData/config/config-save.toml", config)
assert.NoError(t, err, "This should not throw error")
}
func TestSaveConfigSecure(t *testing.T) {
var config tomlConfig
InitConfig("../testingdata/testData/config/config.toml", &config)
key := "1234567891234567"
err := SaveConfigSecure("../testingdata/testData/config/config-save-secure.toml", config, []byte(key))
assert.NoError(t, err, "This should not throw error")
}
func TestInitConfigSecure(t *testing.T) {
var config tomlConfig
InitConfig("../testingdata/testData/config/config.toml", &config)
key := "1234567891234567"
SaveConfigSecure("../testingdata/testData/config/config-save-secure.toml", config, []byte(key))
_, err := InitConfigSecure("../testingdata/testData/config/config-save-secure.toml", &config, []byte(key))
fmt.Println("config: ", config)
assert.NoError(t, err, "This should not throw error")
}