File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,13 @@ func (b *BasicData) Validate() error {
121121 return errors .New ("test end time is missing. We cannot query Loki without a time range. Please set it and try again" )
122122 }
123123
124+ if b .TestEnd .Before (b .TestStart ) {
125+ return errors .New ("test end time is before test start time. Please set valid times and try again" )
126+ }
127+ if b .TestEnd .Sub (b .TestStart ) < time .Second {
128+ return errors .New ("test duration is less than a second. Please set a valid time range and try again" )
129+ }
130+
124131 if len (b .GeneratorConfigs ) == 0 {
125132 return errors .New ("generator configs are missing. At least one is required. Please set them and try again" )
126133 }
Original file line number Diff line number Diff line change @@ -277,6 +277,33 @@ func TestBenchSpy_TestBasicData_Validate(t *testing.T) {
277277 wantErr : true ,
278278 errMsg : "generator configs are missing" ,
279279 },
280+ {
281+ name : "test start and end time are the same" ,
282+ bd : & BasicData {
283+ TestStart : time .Now (),
284+ TestEnd : time .Now (),
285+ },
286+ wantErr : true ,
287+ errMsg : "test duration is less than a second" ,
288+ },
289+ {
290+ name : "test end time before start time" ,
291+ bd : & BasicData {
292+ TestStart : time .Now ().Add (time .Hour ),
293+ TestEnd : time .Now (),
294+ },
295+ wantErr : true ,
296+ errMsg : "test end time is before test start time" ,
297+ },
298+ {
299+ name : "test end time are start time < 1s apart" ,
300+ bd : & BasicData {
301+ TestStart : time .Now (),
302+ TestEnd : time .Now ().Add (time .Second - time .Millisecond ),
303+ },
304+ wantErr : true ,
305+ errMsg : "test duration is less than a second" ,
306+ },
280307 }
281308
282309 for _ , tt := range tests {
You can’t perform that action at this time.
0 commit comments