Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Golang API Testing the HARD way
Search
Seiji Takahashi
November 25, 2018
Programming
13
6.4k
Golang API Testing the HARD way
Presentations at GoConference 2018 Autumn.
Seiji Takahashi
November 25, 2018
Tweet
Share
More Decks by Seiji Takahashi
See All by Seiji Takahashi
Go Backends for frontends with GraphQL and gRPC
timakin
6
3.7k
Design Pattern for Image and Text Composition in Go
timakin
5
6.5k
Head First Golang Image Package
timakin
2
10k
React Native Beyond Prototype
timakin
2
1.6k
Performance Optimization on Google AppEngine
timakin
5
6.2k
testcache.pdf
timakin
1
130
How Go cache
timakin
1
66
How Go cache tests
timakin
1
2.9k
A/Bテスト機構がもたらす 大胆な開発体制及び ゆるやかなアプリ体験の変化 / Architecture and benefits of AB-test allocation system.
timakin
4
7.6k
Other Decks in Programming
See All in Programming
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
100
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
2
260
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
390
Recoilを剥がしている話
kirik
5
6.7k
Go の GC の不得意な部分を克服したい
taiyow
3
790
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
380
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
130
Security_for_introducing_eBPF
kentatada
0
110
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
快速入門可觀測性
blueswen
0
360
fs2-io を試してたらバグを見つけて直した話
chencmd
0
230
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Gamification - CAS2011
davidbonilla
80
5.1k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
Building Adaptive Systems
keathley
38
2.3k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
4 Signs Your Business is Dying
shpigford
181
21k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Transcript
API TESTING THE HARD WAY @__timakin__ Go CONFERENCE 2018 Autumn
SEIJI TAKAHASHI timakin @__timakin__ __timakin__ ॴଐɿ(VOPTZ*ODϝσ ΟΞࣄۀຊ෦ ݴޠɿ(P 4XJGU +BWB4DSJQU
ΞδΣϯμ w (Pͷ"1*ͷςετʹ͓͚ΔςελϏϦςΟ w ςετʹؔ͢Δ5JQT w Ϣχοτςετʹ͍ͭͯ w ΠϯςάϨʔγϣϯςετʹ͍ͭͯ w
ϥΠϒϥϦબఆɺͭ·͍ͮͨՕॴ
None
(Pͷςετϊϋ w ϢχοτςετͷޮԽ w (Pͷ༏Εͨඪ४ػೳ
(Pͷςετϊϋ w ϢχοτςετͷޮԽ w (Pͷ༏Εͨඪ४ػೳ w .PDL w JOUFSGBDFʹΑΔநԽ
(Pͷςετϊϋ w ϢχοτςετͷޮԽ w (Pͷ༏Εͨඪ४ػೳ w .PDL w JOUFSGBDFʹΑΔநԽ w
5FTUJOHGSBNFXPSLT
(Pͷςετϊϋ w ϢχοτςετͷޮԽ w (Pͷ༏Εͨඪ४ػೳ w .PDL w JOUFSGBDFʹΑΔநԽ w
5FTUJOHGSBNFXPSLT w OFUIUUQIUUQUFTUͷ͍ํ
ςετͷ࣮ྫ ʢಛʹΠϯςάϨʔγϣϯςετʣ ͷྫ͕Կނ͔ෆ͍ͯ͠Δʜ
(PͰςετ͢Δ߹ͷجຊ w JOUFSGBDFͷ׆༻ w AQBDLBHFYYY@UFTUAͱ͍͏໋໊ w 5BCMF%SJWFO5FTU w 5FTU$BDIF $PWFSBHF
#FODINBSL
*OUFSGBDFΛ׆༻ͯ͠ΔͱԿ͕͍͍ͷ͔ʁ w ผͷϨΠϠʔͷ࣮ΛΒͣʹίʔυΛॻ͖ਐΊΒ ΕΔ w ࣮ͷΓସ͕͑༰қʹߦ͑Δ w NPDLੜʹ͑Δ w αϯϓϧϨεϙϯεͷ࡞͕͍͠
֎෦"1*ݺͼग़͠ͳͲͰʹཱͭ
AQBDLBHFYYY@UFTUA w 5FTU1BDLBHFΛ࣮ͱ͢Δ w ࣮ࡍͷݺͼग़͠ํͱܗࣜΛ߹ΘͤΔ w QSJWBUFͳมʹର͢Δࢀর͕Ͱ͖ͳ͍Α͏ʹ͢Δ
5BCMF%SJWFO5FTU
5BCMF%SJWFO5FTU w ςετରͱͳΔσʔλྻɺ ظ͞ΕΔ݁ՌͷྻΛΠςϨʔτ͢Δ͜ͱͰ ෳͷςετέʔεΛ؆ܿʹ·ͱΊΒΕΔɻ w ϕϯνϚʔΫΛ͚ͨΓɺU1BSBMMFMΛ͍͍ͨ߹ 4VCUFTUTݕ౼͢Δɻ
5FTU$BDIF $PWFSBHF #FODINBSL w 5FTU$BDIF ςετؔ͝ͱʹ*%͕ৼΒΕͯɺ ݁Ռ͕ϑΝΠϧʹు͖ग़͞Εͯอଘ͞ΕΔɻ Ұக͢Δ݁Ռ͕͋Ε͍ճ͢ɻ w $PWFSBHF
#FODINBSL ඪ४Ͱαϙʔτ͞ΕΔ ΧόϨοδϨϙʔτͷग़ྗɺϕϯνϚʔΫ
$BDIFʹ͍ͭͯʜ IUUQTTQFBLFSEFDLDPNUJNBLJOIPXHPDBDIFUFTUT
(PͰςελϏϦςΟʔΛ্͛Δʹ w ͦͦςετ͕͠ʹ͍͘ίʔυμ ϝ w JOUFSGBDFͰϞοΫՄೳͳ෦ҐΛ૿͢ w ςετϔϧύʔͷॆ࣮ w ϢχοτςετʹدͤΒΕΔͱ͜Ζ
పఈͯ͠دͤΔׂͱେࣄ
(PͰςελϏϦςΟʔΛ্͛Δʹ w ϢχοτςετͷͨΊͷඪ४ػೳ͕ ॆ࣮͍ͯ͠ΔͷͰɺͦΕΛ׆༻͢ΔͨΊʹɺ Ͱ͖ΔݶΓߏମͷςετύοέʔδʹ ϩδοΫΛूதͤ͞Δɻ w 4FSWJDFʹϑΟϧλϦϯάͷϩδοΫΛͨ͠Γ ͠ͳ͍ɻ
͜͜·Ͱ͕લఏ
Ϣχοτςετͷ
Ϣχοτςετͷ5JQT w 5FTU)FMQFS w 4UVCTUBOEBSEQBDLBHFT w 'JYUVSFT w 5FTUJOHGSBNFXPSLT
5FTU)FMQFS U)FMQFS ΛݺͿ͜ͱͰɺ )FMQFSͷؔΛςετΛ ϚʔΫͯ͠ɺGBJMͨ࣌͠ʹ ݺͼग़͠ՕॴΛQSJOUͯ͘͠ΕΔɻ ͜ΕΛݺͳ͍ͱ෦ͰGBJM͠ ͨΓɺॲཧΛڞ௨Խͨ࣌͠ʹਏ ͍ࢥ͍Λ͢Δɻ
5FTU)FMQFS ඪ४ύοέʔδͷςετಛʹ)FMQFS͕׆༻͞Ε͍ͯΔ ʢSVO DPQZ'JMF OFX5FNQ%JSʣ
4UVCTUBOEBSEQBDLBHFT w UJNFύοέʔδɺSBOEύοέʔδͳͲͷ݁ՌΛ͏ ॲཧTUVC͢Δඞཁ͕͋Δ
ελϒํ๏ w άϩʔόϧมͷࠩ͠ସ͑ w ελϒՄೳͳϥούʔ w αʔυύʔςΟύοέʔδͷར༻
άϩʔόϧมͷࠩ͠ସ͑ άϩʔόϧͳมͰมΘΓ͏Δ݁ՌΛऔಘ͢ ΔΑ͏ʹ͠ɺςετ࣌ͦΕΛॻ͖͑Δɻ ಉ͡ͳΒͱ͔͘ɺQBSBMMFMͰͬͨ࣌ʹෆ ͕҆͋Δɻ HPSN͕ͬͯΔʜ IUUQTHJUIVCDPNKJO[IVHPSNCMPCNBTUFSVUJMTHP-
ελϒՄೳͳϥούʔ ελϒ༻ͷ͕ηοτ͞Εͯ ͍ͨΒఆతʹΛฦؔ͢Λ ఆٛ͢Δɻ
αʔυύʔςΟύοέʔδͷར༻ w ࣌ࠁݻఆ w HJUIVCDPNCFOCKPIOTPODMPDL w HJUIVCDPNULVDIJLJGBLFUJNF w DPEFDMPVEGPVOESZPSHDMPDL
4UVCTUBOEBSEQBDLBHFT w ʮ༗ޮظݶΛա͗ͨΒΤϯςΟςΟΛແޮԽ͢Δʯ Έ͍ͨͳॲཧ͕͋Δ߹ɺ࣌ࠁΛ୯७ʹݻఆ͢Δͩ ͚Ͱͳ͘ਐΊΔඞཁ͕͋Δ w ͦ͏ͨ͠߹αʔυύʔςΟͷύοέʔδߟ ྀʹೖΕΔ͕ɺʢ͍ͩͿ࣮͕গͳ͍ͷͰʣ جຊతʹؔͰϥοϓ͢ΕࣄΓΔͱࢥΘΕΔɻ
'JYUVSFT w ςετσʔλͷఆٛํ๏ w ߏମ w ྻͷσʔλߏʢ5BCMF%SJWFO5FTUʣ w ͦͷଞ w
+40/ :".-
'JYUVSFT w ߏମ w ϙΠϯλΛड͚औͬͯૢ࡞͢ΔؔΛςετ͢Δ ߹ɺςετ༻ͷมͷݩσʔλ͕มΘΓଓ͚ͯɺ ҙਤ͠ͳ͍ڍಈ͕ى͜Δɻ w 5BCMF%SJWFO5FTUͷΑ͏ʹݸผͷέʔεͰࢀর͢ Δσʔλ͕ҧ͏߹0,
'JYUVSFT w +40/ :".- w JPVUJM3FBE'JMFͯ͠ςετσʔλΛಡΈࠐΉ w ಡΈࠐΈ༻ͷσʔλJOQVU ·ͨTSD
ൺֱ༻ͷσʔλHPMEFO w "1*ͷϦΫΤετͱϨεϙϯεΛ શ෦+40/ఆ͓͍ٛͯͯ͠ςετ͢Δͷ͋Γ
'JYUVSFT w JOQVUHPMEFO w ඪ४ύοέʔδͰͷར༻Օॴ w ςετΧόϨοδϖʔδͷ༰ݕূ w (PEPDੜ༰ݕূ
'JYUVSFT w JOQVUHPMEFO w ඪ४ύοέʔδͰͷར༻Օॴ w ςετΧόϨοδϖʔδͷ༰ݕূ w (PEPDੜ༰ݕূ w
࣮ࡍͷར༻ྫ w "1*ͷϦΫΤετͱϨεϙϯεΛ શ෦+40/ఆ͓͍ٛͯͯ͠ςετ͢Δ w εςʔλείʔυ͚ͩνΣοΫ͢ΔΑ͏ͳ߹ɺ ϦΫΤετ͚ͩA TSDAͱ͍͏Α͏ͳ໋໊Ͱఆٛ͢Δͷ͋Γ
5FTUJOHGSBNFXPSLT w ʮ(Pͬͯɺ\\ҙͷݴޠ໊^^Ͱ͍͏ͱ͜Ζ\\ͦͷݴޠͷදత ͳςετϑϨʔϜϫʔΫ໊^^ͬͯͳΜ͔ͳ͍ΜͰ͔͢ʁʯ w "1*ϑϨʔϜϫʔΫͰಉ͕ٞ͋͡Δͱࢥ͍·͕͢ʜ
5FTUJOHGSBNFXPSLT w ʮ(Pͬͯɺ\\ҙͷݴޠ໊^^Ͱ͍͏ͱ͜Ζ\\ͦͷݴޠͷදత ͳςετϑϨʔϜϫʔΫ໊^^ͬͯͳΜ͔ͳ͍ΜͰ͔͢ʁʯ w "1*ϑϨʔϜϫʔΫͰಉ͕ٞ͋͡Δͱࢥ͍·͕͢ʜ w ςετϑϨʔϜϫʔΫͷੋඇ w ଞͷਓ͕ແݶʹޠ͍ͬͯΔͷͰলུ
w ʮͨͩͷ%4-ʯ w ʮίϯςΩετʹ͋ͬͨϝοηʔδදࣔʯ w ʮUFTUJOHͰඞཁेʯ w ʮϝϯςอূʯ w ʮπʔϧؒͷ࿈ܞͷऔΓ͢͞ʯ
5FTUJOHGSBNFXPSLT w ͜Ε͘Β͍ͳΒೖΕͯΑ͘ͳ͍ʁͱ͍͏ύοέʔδ w HJUIVCDPNHPPHMFHPDNQ w HJUIVCDPNTUSFUDISUFTUJGZ w 5BCMF%SJWFO5FTUͰͪΌΜͱςετέʔε໊ॻ͍͓͚ͯ ࠔΔ͜ͱগͳ͍ͷͰผʹ͍Βͳ͍͔
5FTUJOHGSBNFXPSLT w ͜Ε͘Β͍ͳΒೖΕͯΑ͘ͳ͍ʁͱ͍͏ύοέʔδ w HJUIVCDPNHPPHMFHPDNQ w HJUIVCDPNTUSFUDISUFTUJGZ w 5BCMF%SJWFO5FTUͰͪΌΜͱςετέʔε໊ॻ͍͓͚ͯ ࠔΔ͜ͱগͳ͍ͷͰผʹ͍Βͳ͍͔
w ݸਓతʹೖΕͳ͍ύοέʔδ w ඞཁेͳͣͷUFTUJOHύοέʔδͷϥούʔ w HPUFTUUPPMT w (P$POWFZ w (PCMJO
ΠϯςάϨʔγϣϯςετͷ
ΠϯςάϨʔγϣϯςετʹඞཁͳ͜ͱ w ࣮ߦڥ w %# DBDIF w 'JYUVSF w ࣌ࠁɾཚݻఆ
w DPOUFYUม w ֎෦"1*ͷ.PDL w "1*SFRSFTͷݕূ
࣮ߦڥͷߏங w %#ɺDBDIFΛͲͷΑ͏ʹཱͯΔ͔ w .PDL͢Δ w σʔϞϯ࣮ߦ w EPDLFSίϯςφΛཱͯΔ
%#पΓͰඞཁͳ࡞ۀ w ςετ࣮ߦ͝ͱʹҎԼͷϑϩʔΛ౿Ή ίωΫγϣϯཱ֬ ςʔϒϧ࡞ Ϛελσʔλద༻
ςετ࣮ߦ ςʔϒϧഁغ ίωΫγϣϯஅ
%#Λ.PDL͢Δͷྑ͍͔ʁ w ͋·ΓϕλʔͰͳ͍ͱࢥ͏ w 42-จ͕ؒҧ͍ͬͯΔ͔Ͳ͏͔ίϯύΠϧ࣌ʹ ؾ͚ͮͳ͍ w αʔυύʔςΟ"1*ͳΒ·ͩ͠ɺ%#ͳΒࣗͰ ڥ͕༻ҙͯ͠ɺҙਤ௨Γ͔Ͳ͏͔ͷݕূ͕ Ͱ͖Δͷ͔ͩΒɺ.PDL͠ͳ͍ํ͕ྑ͍
σʔϞϯ࣮ߦ w HJUIVCDPNMFTUSSBUHPUFTUNZTRME w Կߟ͑ͳͯ͘NZTRME͕࣮ߦͰ͖Δ
ίϯςφ w (PͰ%PDLFSʹଓ͢Δϥούʔ w HJUIVCDPNGTPV[BHPEPDLFSDMJFOU w HJUIVCDPNPSZEPDLFSUFTU w ςετͷͨΊʹ.Z42-3FEJTଓ͕Ͱ͖Δ ྗڧ͍ϥούʔ
w ࣗલͰEPDLFSίϯςφͨͯΔ࣌ʹඞཁͳ ىಈ֬ೝऔΕΔ·Ͱͷ1JOHͳͲΛͬͯ͘ΕΔ
ίϯςφ
γϯϓϧͳଓ %#ͷίωΫγϣϯͳͲɺ DMPTFͷॲཧ͕ඞཁͳ ͷɺ UFBSEPXO༻ͷGVODΛฦ ٫͓͍ͯͯ͠ɺ ࢀর͍ͯ͠ΔؔͰ EFGFSͰ࣮ߦ͢Δͱ ҆શɻ
'JYUVSF w ϢχοτςετͱҟͳΓ༻్͕͍͔ͭ͋͘Δ w SFRSFTݕূ༻ͷQBZMPBE w ࣄલʹ%#ʹೖΕ͓ͯͨ͘Ίͷσʔλ w ڞ௨ͷϚελσʔλ w
ݸผͷςετ༻ʹ༻ҙ͞Εͨσʔλ
SFRSFTݕূ༻ͷQBZMPBE w JOQVUHPMEFOͰQBZMPBEΛ+40/ʹ·ͱΊ͓ͯ͘ w ΫΤϦύϥϝʔλʔඞཁͳΒΓग़͓ͯ͘͠
ςʔϒϧ࡞ɾআ w ςʔϒϧఆ͕ٛΒͭ͘ͱ໘ͳͷͰɺ HJUIVCDPNLLVCVOTRMEFGΛͬͯ ҰݸͷεΩʔϚʹ࠷৽ͷঢ়ଶΛ·ͱΊ͓ͯ͘ͱศར
ςʔϒϧ࡞ɾআ
None
Ϛελσʔλςετ͝ͱͷσʔλ w ݸਓతʹҎԼͷΑ͏ʹɺϚελσʔλͱͦΕҎ֎ Λ͚͍ͯΔ w UFTUEBUBpYUVSFTEFGBVMU w Ϛελσʔλ w UFTUEBUBpYUVSFTPQUJPOBM
w ςετέʔεʹΑͬͯࢀরͨ͠Γ͠ͳ͔ͬͨΓ͢ Δσʔλ
σʔλ࡞
σʔλ࡞
ಛघͳσʔλૠೖ w .Z42- 1PTHSF42-ͳͲͷσʔλૠೖָ w ("&ΛͬͯΔͱ%BUBTUPSFʹ 'JYUVSFΛೖΕͨ͘ͳΔ
None
ETNPDL w 'JYUVSFͷ:".-ఆٛΛࢦఆ͢Εɺࢦఆͷ,JOEͷ σʔλΛྲྀ͠ࠐΊΔ w $MFBOVQ࡞ۀผ్ඞཁ
࣌ࠁɾཚݻఆ w ௨ৗͷςετͱಉ༷ɻϞοΫ༻ͷؔΛఆٛͯ͠ɺ Ϧηοτ༻ͷؔΛSFUVSOͯ͠ྑ͍ɻ
$POUFYUม w DPOUFYU෦ͷΛͬͯॲཧ͢Δ߹ɺUFTU༻ͷDPOUFYUʹ ΛೖΕ͓ͯ͘ඞཁ͕͋Δ w ଟօ͞Μ͕෦Ͱఆ͍ٛͯ͠Δ/FX$POUFYU8JUI999ͳϝ ιουΛݺͿͷྑ͍͕ɺͪΌΜͱϦΫΤετͱͯ͠ ݕূ͢ΔͳΒͤΊͯSFRʹΛૠೖ͓͖͍ͯͨ͠ɻ
֎෦"1*ͷ.PDL w ֎෦"1*͏Ͳ͏͠Α͏ͳ͍ͷͰ.PDL͢Δ w NPDLೖΕͯΔͷʹͬͯͳ͍ͱΤϥʔͰऴྃ͢Δ ͷͰɺNPDL͚ͩॲཧΛڞ௨Խͤͣ ɺݸผͷςε τέʔεͰૠೖ͢Δɻ
.PDLͷίϯτϩʔϥʔੜ
.PDLར༻
"1*SFRSFTͷݕূ w HPMBOHHPBQQFOHJOFͷެࣜύοέʔδʹʑ AUSZAͱ͍͏ϥούʔ͕͋Δɻ w ϦΫΤετݕূςετͷग़ྗ݁ՌͳͲͷݕূ AUSZAͱ͍͏ஆ͔͍͕ؔͬͯ͘Εͯͯɺ ඇৗʹ࣮ͷࢀߟʹͳΔ
SFRSFTΛݕূ͢Δ߹ʜ
None
None
؆ૉ☺
͓·͚
5FTU3VOOFSࣗମͷϥούʔ w ΠϯςάϨʔγϣϯςετͰΔ͜ͱ ͍͍ܾͩͨ·ͬͯΔ w UFTUJOH.Λड͚औΔؔͰϥοϓͯ͋͛͠Δͱ εοΩϦ͢Δ
None
·ͱΊ w ۃྗ"1*ͷςετϢχοτςετͰϩδοΫΛ୲อͰ͖ΔΑ ͏ʹɺ࣮Λߏମۙ͘ʹدͤΔ w ΠϯςάϨʔγϣϯςετͷϊϋ·ͩ·ͩΦʔϓϯ͡Ό ͳ͍͚Ͳɺެࣜύοέʔδͷஆ͔͍ςετ͕ඇৗʹࢀߟʹͳΔ w γϯϓϧ͞ΛอͪͭͭɺͲ͜·Ͱڞ௨ԽͰ͖Δ͔͕ޣຯͳͷ ͰɺͦΕΛָ͠Έ·͠ΐ͏
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ