Files

37 lines
950 B
Go
Raw Permalink Normal View History

package contract
import (
"encoding/json"
"reflect"
"testing"
)
func TestEnvelopeUsesUploadInfoWithBaseAndManageInfo(t *testing.T) {
envelope := Envelope{
ServiceID: "JKDA00002",
UploadInfo: UploadInfo{
BaseInfo: map[string]string{"idCard": "440100199001011234"},
ManageInfo: ManageInfo{
DSFMC: "dyytgw",
OperateUser: "712041",
OperateUnit: "12441625456962881G",
},
},
}
raw, err := json.Marshal(envelope)
if err != nil {
t.Fatalf("Marshal: %v", err)
}
want := `{"serviceId":"JKDA00002","uploadinfo":{"baseInfo":{"idCard":"440100199001011234"},"manageInfo":{"DSFMC":"dyytgw","operateUser":"712041","operateUnit":"12441625456962881G"}}}`
if string(raw) != want {
t.Fatalf("envelope JSON = %s", raw)
}
}
func TestEnvelopeDoesNotExposeTopLevelBaseInfo(t *testing.T) {
if _, ok := reflect.TypeOf(Envelope{}).FieldByName("BaseInfo"); ok {
t.Fatal("Envelope exposes obsolete top-level BaseInfo")
}
}