<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>mkk45</author_name>
  <author_url>https://blog.hatena.ne.jp/mkk45/</author_url>
  <blog_title>3歩進んで2歩下がる</blog_title>
  <blog_url>https://mkk45.hatenablog.com/</blog_url>
  <categories>
  </categories>
  <description>アプリケーションを開発していると現在日時を使いたい場面に遭遇します。 このような場面で time.Now() の出力はその時々で変化していくため、テストを書く際に工夫が必要です。 例えば、JavaScriptのテストライブラリJestでは以下のように実行時の日時を固定化する モック機構 が提供されています。 jest.useFakeTimers(); jest.spyOn(global, 'setTimeout'); test('waits 1 second before ending the game', () =&gt; { const timerGame = require('../timer…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fmkk45.hatenablog.com%2Fentry%2F2025%2F03%2F27%2F144435&quot; title=&quot;Goでテスタブルに現在日時を扱いたい - 3歩進んで2歩下がる&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2025-03-27 14:44:35</published>
  <title>Goでテスタブルに現在日時を扱いたい</title>
  <type>rich</type>
  <url>https://mkk45.hatenablog.com/entry/2025/03/27/144435</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
