Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Goのinterfaceを使って外部サービスに依存しないテストを書く #go #golang ...
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Toshinori Sugita
May 28, 2018
Technology
9k
6
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Goのinterfaceを使って外部サービスに依存しないテストを書く #go #golang / mock external service with golang interface
Toshinori Sugita
May 28, 2018
More Decks by Toshinori Sugita
See All by Toshinori Sugita
AIエージェント時代のPlatform as a Product —— テックリードがPdMとして回す発見・導入・計測 / Platform as a Product in the AI Agent Era
toshi0607
1
700
GKEを中心としたマルチプロダクト・マルチリージョン対応アプリケーションプラットフォームの継続的改善 / continuous improvement of GKE based application platform
toshi0607
1
240
組織を巻き込む大規模プラットフォーム移行戦略 〜50+サービスのマルチリージョン・マルチプロダクト化で学んだステークホルダー協働の実践〜 / Platform migration strategy engaging all stakeholders
toshi0607
2
8k
文系学部卒ソフトウェアエンジニアが Georgia Techコンピューターサイエンス修士課程で直面したもの / What a Liberal Arts Graduate Software Engineer Faced in Georgia Tech's Computer Science Master's Program
toshi0607
4
2.1k
50以上のマイクロサービスを支えるアプリケーションプラットフォームの設計・構築の後悔と進化 #CNDW2024 / regrets and evolution of application platform
toshi0607
5
9.8k
OPA and cloud resources
toshi0607
1
14k
KompalWeather: Serverless Sauna Service with Cloud Run
toshi0607
1
13k
Knativeで作るDIY FaaS / serverless days fukuoka 2019 knative workshop
toshi0607
1
5.4k
Knativeで作るDIY FaaS / serverless days tokyo 2019 knative workshop
toshi0607
5
12k
Other Decks in Technology
See All in Technology
事業成長とデータ活用を止めないためのマネジメントへ挑戦
hiracky16
0
420
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
330
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
1.4k
QA4AI 2026-Oct 生成AI時代の品質保証
tokuty
1
930
ソフトウェア ファクトリー - 再現性のあるソフトウェアの工場づくり / Software factory
iktakahiro
7
5.2k
【データ横丁主催】AI エージェント時代のTranslytical Data Platform
shisyu_gaku
0
150
dbt Semantic Layerで進めるenechainのデータ民主化
akizhou
1
160
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
130
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
140
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
370
PHPカンファレンス関西の招待状 / Invitation to PHP Conference Kansai
ykanoh
0
220
オントロジーって 結局なにもの? AI エージェントに「意味」を渡す知識設計の話
greenmidori
0
250
Featured
See All Featured
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
530
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
410
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
What's in a price? How to price your products and services
michaelherold
247
13k
WCS-LA-2024
lcolladotor
0
900
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
460
Claude Code のすすめ
schroneko
67
230k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
270
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.3k
Become a Pro
speakerdeck
PRO
31
6.3k
Transcript
Goのinterfaceを使って 外部サービスに依存しないテストを書く 2018/5/28 Gopher道場#1 LT大会 @toshi0607
自己紹介 • 杉田 寿憲 ◦ Toshinori Sugita ◦ toshi0607 ◦
toshi0607 ◦ toshi0607 • 最近の様子 ◦ Ruby > JavaScript >>> Go >>>>>> C# • 8月にクロアチア旅行することにした
Goで作り直す.gitignore生成コマンド 2018/5/14 Gopher道場最終回 ※https://speakerdeck.com/toshi0607/reinvent-gitignore-command-using-golang
※https://github.com/toshi0607/gig before
※https://github.com/toshi0607/gig before after
今日のお話 • release-tweeterというAPIを作った • 作ったきっかけ • 課題と解決策 • まとめ
今日のお話 • release-tweeterというAPIを作った • 作ったきっかけ • 課題と解決策 • まとめ
release-tweeterとは? ※https://github.com/toshi0607/release-tweeter
release-tweeterとは? ※https://github.com/github/release-tweeter
今日のお話 • release-tweeterというAPIを作った • 作ったきっかけ • 課題と解決策 • まとめ
作ったきっかけ • コマンドの次はAPI作ってみたい • リリースのお知らせ(twitter)も自動化したい • AWS Lambda(Go)とAPI Gateway使ってみたい
AWS LambdaのGoサポート ※https://twitter.com/awscloud/status/953343724909670400
API GatewayとAWS Lambda
今日のお話 • release-tweeterというAPIを作った • 作ったきっかけ • 課題と解決策 • まとめ
課題 CIでテスト回したいけど…
課題 テストを回すたびにtweet
前提 • ChimeraCoder/anaconda(第三者のtwitter clientライブラリ)利用 • URLを差し替えたりはできない(たぶん) • このライブラリも投稿はテストしてない ◦ 自分にDMするテストはしてる
※https://github.com/ChimeraCoder/anaconda
解決策① • 捨てアカ準備
解決策① • 捨てアカ準備 すいませんなんでもないです
解決策② • ライブラリを使わずに再実装
解決策② • ライブラリを使わずに再実装 便利なライブラリ見つけても再実装...
解決策③ • 関数だけ差し替える
解決策③ • 関数だけ差し替える
解決策③ • 関数だけ差し替える
解決策③ • 関数だけ差し替える 差し替えたい対象が増えても1つずつ代入...?
解決策④ • interfaceを活用して差し替える
解決策④ • interfaceを活用して差し替える
解決策④ • interfaceを活用して差し替える
解決策④ • interfaceを活用して差し替える interfaceを満たせば代入可能
ちなみにGitHubでは...
今日のお話 • release-tweeterというAPIを作った • 作ったきっかけ • 課題と解決策 • まとめ
まとめ テストでは外部サービスに依存せずモックしましょう
ご清聴ありがとうございました! Goのinterfaceを使って 外部サービスに依存しないテストを書く