package knowledge import "testing" func TestValidateContent(t *testing.T) { tests := []struct { name string content map[string]interface{} wantErr bool }{ {name: "valid", content: map[string]interface{}{"standard_copy": "标准表达", "risk_note": "风险提示"}}, {name: "missing standard copy", content: map[string]interface{}{"risk_note": "风险提示"}, wantErr: true}, {name: "blank standard copy", content: map[string]interface{}{"standard_copy": " "}, wantErr: true}, {name: "invalid risk note", content: map[string]interface{}{"standard_copy": "标准表达", "risk_note": 1}, wantErr: true}, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { if err := validateContent(test.content); (err != nil) != test.wantErr { t.Fatalf("validateContent() error = %v, wantErr %v", err, test.wantErr) } }) } }