github.com/futurehomeno/fimpgo@v1.14.0/edgeapp/configs_test.go (about)

     1  package edgeapp
     2  
     3  import "testing"
     4  
     5  type AppConf struct {
     6  	Prop1 string
     7  }
     8  
     9  func TestConfigs_LoadFromFile(t *testing.T) {
    10  	cf := Configs{}
    11  	cf.path = "./config_test.json"
    12  	ac := AppConf{Prop1: "39"}
    13  	cf.SetCustomConfigs(ac)
    14  	cf.SaveToFile()
    15  
    16  	cf2 := Configs{}
    17  	cf2.path = "./config_test.json"
    18  	cf2.SetCustomConfigs(&AppConf{})
    19  	cf2.LoadFromFile()
    20  	ac2 := cf2.GetCustomConfigs()
    21  	t.Log("Custom conf:",ac2.(*AppConf).Prop1)
    22  }