included_test.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package model
  2. import (
  3. "reflect"
  4. "testing"
  5. "app.yhyue.com/moapp/jybase/mongodb"
  6. "app.yhyue.com/moapp/jybase/mysql"
  7. )
  8. var (
  9. BaseMysql *mysql.Mysql
  10. MgoJy mongodb.MongodbSim
  11. )
  12. func init() {
  13. BaseMysql = &mysql.Mysql{
  14. Address: "192.168.3.217:4000",
  15. UserName: "root",
  16. PassWord: "=PDT49#80Z!RVv52_z",
  17. DBName: "base_service",
  18. MaxOpenConns: 5,
  19. MaxIdleConns: 5,
  20. }
  21. //mongo初始化
  22. MgoJy = mongodb.MongodbSim{
  23. MongodbAddr: "192.168.3.206:27080",
  24. Size: 50,
  25. DbName: "qfw",
  26. }
  27. MgoJy.InitPool()
  28. }
  29. func TestIncluded_GetIncludedData(t *testing.T) {
  30. type fields struct {
  31. MysqlDb *mysql.Mysql
  32. Mgo *mongodb.MongodbSim
  33. }
  34. tests := []struct {
  35. name string
  36. fields fields
  37. want *IncludedData
  38. wantErr bool
  39. }{
  40. // TODO: Add test cases.
  41. }
  42. for _, tt := range tests {
  43. t.Run(tt.name, func(t *testing.T) {
  44. this := &Included{
  45. MysqlDb: BaseMysql,
  46. Mgo: MgoJy,
  47. }
  48. got, err := this.GetIncludedData()
  49. if (err != nil) != tt.wantErr {
  50. t.Errorf("GetIncludedData() error = %v, wantErr %v", err, tt.wantErr)
  51. return
  52. }
  53. if !reflect.DeepEqual(got, tt.want) {
  54. t.Errorf("GetIncludedData() got = %v, want %v", got, tt.want)
  55. }
  56. })
  57. }
  58. }
  59. func Test_formdataNum(t *testing.T) {
  60. type args struct {
  61. num int64
  62. }
  63. tests := []struct {
  64. name string
  65. args args
  66. wantFloatNum float64
  67. wantUnit string
  68. }{
  69. // TODO: Add test cases.
  70. }
  71. for _, tt := range tests {
  72. t.Run(tt.name, func(t *testing.T) {
  73. gotFloatNum, gotUnit := formdataNum(tt.args.num)
  74. if gotFloatNum != tt.wantFloatNum {
  75. t.Errorf("formdataNum() gotFloatNum = %v, want %v", gotFloatNum, tt.wantFloatNum)
  76. }
  77. if gotUnit != tt.wantUnit {
  78. t.Errorf("formdataNum() gotUnit = %v, want %v", gotUnit, tt.wantUnit)
  79. }
  80. })
  81. }
  82. }