Skip to content

Commit

Permalink
improve time test
Browse files Browse the repository at this point in the history
  • Loading branch information
querwurzel committed Nov 11, 2024
1 parent 0d72107 commit 940afac
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.github.binpastes.paste.domain;

import com.github.binpastes.paste.domain.Paste.PasteExposure;
import org.assertj.core.data.TemporalUnitWithinOffset;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -86,8 +88,8 @@ void markAsExpired(LocalDateTime dateOfExpiry, boolean exceptionExpected) {
} else {
paste.markAsExpired();

assertThat(paste.getDateOfExpiry().withSecond(0).withNano(0))
.isEqualTo(LocalDateTime.now().withSecond(0).withNano(0));
assertThat(paste.getDateOfExpiry())
.isCloseTo(LocalDateTime.now(), new TemporalUnitWithinOffset(59, ChronoUnit.SECONDS));
}
}

Expand Down

0 comments on commit 940afac

Please sign in to comment.