123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- package service
- import (
- "reflect"
- "testing"
- elastic "app.yhyue.com/moapp/jybase/esv1"
- "app.yhyue.com/moapp/jybase/mysql"
- "bp.jydev.jianyu360.cn/ApplicationCenter/medicalField/entity"
- )
- var PortService PortraitService
- var MyConn *entity.Conn
- func init() {
- entity.Mysql = &mysql.Mysql{
- Address: "192.168.3.217:4000",
- UserName: "root",
- PassWord: "=PDT49#80Z!RVv52_z",
- DBName: "medical_fileld_data",
- MaxOpenConns: 5,
- MaxIdleConns: 5,
- }
- entity.Mysql.Init()
- BaseMysqlConn := &mysql.Mysql{
- Address: "192.168.3.217:4000",
- UserName: "root",
- PassWord: "=PDT49#80Z!RVv52_z",
- DBName: "base_service",
- MaxOpenConns: 5,
- MaxIdleConns: 5,
- }
- BaseMysqlConn.Init()
- CommonMysql := &mysql.Mysql{
- Address: "192.168.3.217:4000",
- UserName: "root",
- PassWord: "=PDT49#80Z!RVv52_z",
- DBName: "global_common_data",
- MaxOpenConns: 5,
- MaxIdleConns: 5,
- }
- CommonMysql.Init()
- MyConn = &entity.Conn{
- Mysql: entity.Mysql,
- BaseMysql: BaseMysqlConn,
- CommonMysql: CommonMysql,
- }
- elastic.InitElasticSize("http://192.168.3.206:9800", 30)
- PortService = *NewPortrait(MyConn)
- }
- func TestPortraitService_Info(t *testing.T) {
- type fields struct {
- Conn *entity.Conn
- }
- type args struct {
- companyId string
- }
- tests := []struct {
- name string
- fields fields
- args args
- want *entity.PortraitInfo
- wantErr bool
- }{
- // TODO: Add test cases.
- {
- name: "查询画像",
- fields: fields{
- Conn: MyConn,
- },
- args: args{
- companyId: "25caa43ce64036dfd1f55635e06394a6",
- },
- },
- {
- name: "无参数查看画像",
- fields: fields{
- Conn: MyConn,
- },
- args: args{
- companyId: "",
- },
- },
- {
- name: "错误参数查看画像",
- fields: fields{
- Conn: MyConn,
- },
- args: args{
- companyId: "错的",
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- this := &PortraitService{
- Conn: tt.fields.Conn,
- }
- got, err := this.Info(tt.args.companyId)
- if (err != nil) != tt.wantErr {
- t.Errorf("Info() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- if !reflect.DeepEqual(got, tt.want) {
- t.Errorf("Info() got = %v, want %v", got, tt.want)
- }
- })
- }
- }
- func TestPortraitService_List(t *testing.T) {
- type fields struct {
- Conn *entity.Conn
- }
- type args struct {
- companyId string
- pagesize int64
- pagenum int64
- }
- tests := []struct {
- name string
- fields fields
- args args
- want *entity.PortraitInfo
- wantErr bool
- }{
- // TODO: Add test cases.
- {
- name: "招标动态",
- fields: fields{
- Conn: MyConn,
- },
- args: args{
- companyId: "张家港市凤凰镇人民政府",
- pagesize: 5,
- pagenum: 1,
- },
- },
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- this := &PortraitService{
- Conn: tt.fields.Conn,
- }
- got, _, err := this.List(tt.args.companyId, tt.args.pagesize, tt.args.pagenum)
- if (err != nil) != tt.wantErr {
- t.Errorf("Info() error = %v, wantErr %v", err, tt.wantErr)
- return
- }
- if !reflect.DeepEqual(got, tt.want) {
- t.Errorf("Info() got = %v, want %v", got, tt.want)
- }
- })
- }
- }
|