package auto import ( "testing" "time" ) func TestAutoDoStartAutoPProf(t *testing.T) { p := NewAutoPProf(Config{ MinTriggerValue: "10MB", RecordSensitivity: "1MB", }) err := p.init() if err != nil { t.Error("init err", err) return } type fields struct { config Config fixedQuotient int perHourQuotient []int detectInterval time.Duration recordSensitivity float64 maxDiskUsage float64 periodRecordCount uint } tests := []struct { name string fields fields wantErr bool }{ { name: "normal", fields: fields{ config: p.config, fixedQuotient: p.fixedQuotient, perHourQuotient: p.perHourQuotient, detectInterval: 1 * time.Second, recordSensitivity: p.recordSensitivity, maxDiskUsage: p.maxDiskUsage, periodRecordCount: p.periodRecordCount, }, wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { p := &auto{ config: tt.fields.config, fixedQuotient: tt.fields.fixedQuotient, perHourQuotient: tt.fields.perHourQuotient, detectInterval: tt.fields.detectInterval, recordSensitivity: tt.fields.recordSensitivity, maxDiskUsage: tt.fields.maxDiskUsage, periodRecordCount: tt.fields.periodRecordCount, } if err := p.doStartAutoPProf(); (err != nil) == tt.wantErr { t.Errorf("doStartAutoPProf() error = %v, wantErr %v", err, tt.wantErr) } }) } }