Skip to content

Commit

Permalink
airbyte-14819 tests in S3FilenameTemplateManagerTest should use the s…
Browse files Browse the repository at this point in the history
…ame TZ as the code under test (#14826)
  • Loading branch information
alexandertsukanov authored and mfsiega-airbyte committed Jul 21, 2022
1 parent 57e1e8a commit 4981545
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mockStatic;

import io.airbyte.integrations.destination.s3.S3DestinationConstants;
import io.airbyte.integrations.destination.s3.template.S3FilenameTemplateManager;
import io.airbyte.integrations.destination.s3.template.S3FilenameTemplateParameterObject;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Clock;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.TimeZone;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
Expand All @@ -39,7 +41,12 @@ void testDatePlaceholder()
.fileExtension(fileExtension)
.partId(partId).build());

final String expected = "test-" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy_MM_dd"));
final DateFormat defaultDateFormat = new SimpleDateFormat(S3DestinationConstants.YYYY_MM_DD_FORMAT_STRING);
defaultDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

long currentTimeInMillis = Instant.now().toEpochMilli();

final String expected = "test-" + defaultDateFormat.format(currentTimeInMillis);
assertEquals(expected, actual);
}

Expand Down

0 comments on commit 4981545

Please sign in to comment.