feat:完善项目信息
This commit is contained in:
35
utils/file_test.go
Normal file
35
utils/file_test.go
Normal file
@ -0,0 +1,35 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"gopkg.in/yaml.v2"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
Version int
|
||||
Mapping map[string]string
|
||||
}
|
||||
|
||||
func TestNewFile(t *testing.T) {
|
||||
file, err := os.OpenFile("test.yml", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
enc := yaml.NewEncoder(file)
|
||||
|
||||
err = enc.Encode(config{
|
||||
Version: 7,
|
||||
Mapping: map[string]string{
|
||||
"key": "value1",
|
||||
"key2": "value2",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
return
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"SciencesServer/app/basic/config"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@ -27,11 +25,4 @@ func TestLoadConfig(t *testing.T) {
|
||||
//out := make([]*ManagePatent, 0)
|
||||
//LoadConfig(file, &out)
|
||||
//fmt.Println(AnyToJSON(out))
|
||||
|
||||
file := "../file/sys_industry.json"
|
||||
out := make([]*config.MemoryForIndustry, 0)
|
||||
|
||||
LoadConfig(file, &out)
|
||||
|
||||
fmt.Println(AnyToJSON(out))
|
||||
}
|
||||
|
Reference in New Issue
Block a user