equipment_test.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package service
  2. import (
  3. "context"
  4. "reflect"
  5. "testing"
  6. )
  7. func TestDeviceStatistics_GetDeviceStatistics(t *testing.T) {
  8. type fields struct {
  9. BaseModel BaseModel
  10. BaseEquipment int
  11. LaboratoryEquipment int
  12. UseTime float64
  13. ExperimentalData int
  14. }
  15. type args struct {
  16. ctx context.Context
  17. req *BaseModel
  18. }
  19. base := new(DeviceStatistics)
  20. arg := args{
  21. ctx: context.TODO(),
  22. req: &BaseModel{LaboratoryId: 1},
  23. }
  24. tests := []struct {
  25. name string
  26. fields *DeviceStatistics
  27. args args
  28. want *DeviceStatistics
  29. wantErr bool
  30. }{
  31. {"读取实验数据测试1", base, arg, nil, false},
  32. }
  33. for _, tt := range tests {
  34. t.Run(tt.name, func(t *testing.T) {
  35. d := &DeviceStatistics{
  36. BaseModel: tt.fields.BaseModel,
  37. BaseEquipment: tt.fields.BaseEquipment,
  38. LaboratoryEquipment: tt.fields.LaboratoryEquipment,
  39. UseTime: tt.fields.UseTime,
  40. ExperimentalData: tt.fields.ExperimentalData,
  41. }
  42. got, err := d.GetDeviceStatistics(tt.args.ctx, tt.args.req)
  43. if (err != nil) != tt.wantErr {
  44. t.Errorf("GetDeviceStatistics() error = %v, wantErr %v", err, tt.wantErr)
  45. return
  46. }
  47. if !reflect.DeepEqual(got, tt.want) {
  48. t.Errorf("GetDeviceStatistics() got = %v, want %v", got, tt.want)
  49. }
  50. })
  51. }
  52. }