add edge config and template

This commit is contained in:
singchia
2024-01-17 11:52:52 +08:00
parent af63d6e094
commit 7aad9f99f5
5 changed files with 204 additions and 6 deletions

View File

@@ -1,8 +1,11 @@
package config
import (
"os"
"reflect"
"testing"
"gopkg.in/yaml.v2"
)
func TestParseFlags(t *testing.T) {
@@ -36,3 +39,36 @@ func TestParseFlags(t *testing.T) {
})
}
}
func TestParseFile(t *testing.T) {
conf := &Configuration{
Daemon: Daemon{
RLimit: RLimit{
NumFile: 1024,
},
PProf: PProf{
Addr: "0.0.0.0:6060",
},
},
Edgebound: Edgebound{},
Servicebound: Servicebound{},
Log: Log{},
}
_, err := yaml.Marshal(conf)
if err != nil {
t.Error(err)
return
}
}
func TestGenDefaultConfig(t *testing.T) {
file, err := os.OpenFile("./config.yaml", os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
t.Error(err)
}
defer file.Close()
err = genDefaultConfig(file)
if err != nil {
t.Error(err)
}
}