Commit 276fbd05 authored by Ajit Jagtap's avatar Ajit Jagtap
Browse files

Merge branch 'InitConfigData' into 'devbranch'

Init config data

See merge request !50
parents 6649debd 33beb087
Branches
Tags
2 merge requests!54Devbranch,!50Init config data
Showing with 13 additions and 0 deletions
......@@ -13,6 +13,11 @@ func InitConfig(fpath string, config interface{}) (toml.MetaData, error) {
return toml.DecodeFile(fpath, config)
}
// InitConfigData initConfig using byte array
func InitConfigData(data []byte, config interface{}) (toml.MetaData, error) {
return toml.Decode(string(data), config)
}
// var config tomlConfig
// InitConfig("../testingdata/testData/config/config.toml", &config)
// fmt.Println(config.Name)
......
package configmdl
import (
"io/ioutil"
"testing"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
......@@ -21,6 +22,13 @@ func TestInitConfig(t *testing.T) {
assert.True(t, config.Name == "github.com/OneOfOne/xxhash", "this should not throw error")
}
func TestInitConfigData(t *testing.T) {
var config tomlConfig
ba, _ := ioutil.ReadFile("../testingdata/testData/config/config.toml")
InitConfigData(ba, &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)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment