23 lines
808 B
Go
23 lines
808 B
Go
package config
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
)
|
|
|
|
// GoAdmin converts YAML to JSON before decoding the extension entity. Keep
|
|
// snake_case JSON tags on the fields that are named with initialisms so the
|
|
// values from config.yaml reach the Huohanhan client.
|
|
func TestHuohanhanConfigDecodesSnakeCaseFields(t *testing.T) {
|
|
var cfg Extend
|
|
if err := json.Unmarshal([]byte(`{"huohanhan":{"base_url":"https://erp.example.test","ocr_url":"https://ocr.example.test/ocr"}}`), &cfg); err != nil {
|
|
t.Fatalf("解析扩展配置失败:%v", err)
|
|
}
|
|
if cfg.Huohanhan.BaseURL != "https://erp.example.test" {
|
|
t.Fatalf("base_url 未解码,实际 %q", cfg.Huohanhan.BaseURL)
|
|
}
|
|
if cfg.Huohanhan.OCRURL != "https://ocr.example.test/ocr" {
|
|
t.Fatalf("ocr_url 未解码,实际 %q", cfg.Huohanhan.OCRURL)
|
|
}
|
|
}
|