Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Improve migration tests. #448

Merged
1 commit merged into from
Feb 16, 2022
Merged

Conversation

keiji
Copy link
Collaborator

@keiji keiji commented Oct 8, 2021

Issue 番号 / Issue ID

目的 / Purpose

  • v1.3.0で実行されるStartDateTimeに関するマイグレーション処理のテストケースを改善する

破壊的変更をもたらしますか / Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request の種類 / Pull Request type

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

検証方法 / How to test

コードの入手 / Get the code

git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
dotnet restore

コードの検証 / Test the code


確認事項 / What to check

その他 / Other information

@keiji keiji requested a review from cocoa-dev October 8, 2021 05:28
@keiji keiji self-assigned this Oct 8, 2021
Comment on lines +38 to +39
private static DateTime CreateDateTime(DateTime dateTime)
=> DateTime.ParseExact(dateTime.ToString(FORMAT_DATETIME), FORMAT_DATETIME, null);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一度、現在のフォーマットに基づいて文字列に変換した上でDateTimeとしてパースする(=タイムゾーンを削除する)

var startDateTime = DateTime.UtcNow;
var termsOfServiceLastUpdateDateJst = DateTime.SpecifyKind(CreateTermsUpdateDateTime(JstNow.AddMinutes(1)), DateTimeKind.Unspecified);
var privacyPolicyLastUpdateDateJst = DateTime.SpecifyKind(CreateTermsUpdateDateTime(JstNow.AddMinutes(2)), DateTimeKind.Unspecified);
var startDateTime = CreateDateTime(DateTime.UtcNow);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startDateTimeについてもタイムゾーンを取り除く

@@ -731,7 +731,8 @@ await CreateService()

// StartDateTime
var startDateTimePref = _dummyPreferencesService.GetValue(PreferenceKey.StartDateTimeEpoch, 0L);
Assert.Equal(startDateTime.ToUnixEpoch(), startDateTimePref);
var startDateTimeUtc = DateTime.SpecifyKind(startDateTime, DateTimeKind.Utc);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この時点ではstartDateTimeからはタイムゾーン情報がないので正しくUnixEpochに変換できないため、DateTimeKind.Utcを付け直す。

この処理はテストの想定される値を正しく計算するためのもの、マイグレーション処理そのものには作用しない。

@keiji keiji marked this pull request as ready for review October 8, 2021 05:35
@kazuhiro4949
Copy link
Collaborator

kazuhiro4949 commented Nov 3, 2021

手元でのテストの実行結果も問題なさそうです

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

私の環境でもテスト通りました。問題ないと思います。

@ghost ghost merged commit 514594f into cocoa-mhlw:develop Feb 16, 2022
@ghost
Copy link

ghost commented Feb 16, 2022

@keiji
マージしました。

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

マイグレーション処理のテストケースを改善する
2 participants