From e74e5203f31219922160f83349f417328e120a50 Mon Sep 17 00:00:00 2001 From: Matthias Fasching Date: Tue, 16 Nov 2021 09:49:19 +0000 Subject: [PATCH 1/4] Upgrade dependencies --- go.mod | 14 ++++---- go.sum | 109 ++++++++++++++++++++++++++++++++------------------------- 2 files changed, 68 insertions(+), 55 deletions(-) diff --git a/go.mod b/go.mod index 1262630..7c4608f 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,14 @@ module github.com/gobuffalo/genny/v2 -go 1.13 +go 1.16 require ( - github.com/gobuffalo/logger v1.0.3 - github.com/gobuffalo/packd v1.0.0 - github.com/gobuffalo/plush/v4 v4.0.0 + github.com/gobuffalo/logger v1.0.6 + github.com/gobuffalo/packd v1.0.1 + github.com/gobuffalo/plush/v4 v4.1.8 github.com/markbates/oncer v1.0.0 github.com/markbates/safe v1.0.1 - github.com/sirupsen/logrus v1.5.0 - github.com/stretchr/testify v1.5.1 - golang.org/x/tools v0.0.0-20200323192200-8849913b6971 + github.com/sirupsen/logrus v1.8.1 + github.com/stretchr/testify v1.7.0 + golang.org/x/tools v0.1.7 ) diff --git a/go.sum b/go.sum index 701aa04..9c240d9 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +1,35 @@ +github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= +github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= -github.com/gobuffalo/flect v0.2.0 h1:EWCvMGGxOjsgwlWaP+f4+Hh6yrrte7JeFL2S6b+0hdM= github.com/gobuffalo/flect v0.2.0/go.mod h1:W3K3X9ksuZfir8f/LrfVtWmCDQFfayuylOJ7sz/Fj80= -github.com/gobuffalo/github_flavored_markdown v1.1.0 h1:8Zzj4fTRl/OP2R7sGerzSf6g2nEJnaBEJe7UAOiEvbQ= +github.com/gobuffalo/flect v0.2.3 h1:f/ZukRnSNA/DUpSNDadko7Qc0PhGvsew35p/2tu+CRY= +github.com/gobuffalo/flect v0.2.3/go.mod h1:vmkQwuZYhN5Pc4ljYQZzP+1sq+NEkK+lh20jmEmX3jc= github.com/gobuffalo/github_flavored_markdown v1.1.0/go.mod h1:TSpTKWcRTI0+v7W3x8dkSKMLJSUpuVitlptCkpeY8ic= -github.com/gobuffalo/helpers v0.6.0 h1:CL1xOSGeKCaKD1IUpo4RfrkDU83kmkMG4H3dXAS7dw0= -github.com/gobuffalo/helpers v0.6.0/go.mod h1:pncVrer7x/KRvnL5aJABLAuT/RhKRR9klL6dkUOhyv8= -github.com/gobuffalo/logger v1.0.3 h1:YaXOTHNPCvkqqA7w05A4v0k2tCdpr+sgFlgINbQ6gqc= -github.com/gobuffalo/logger v1.0.3/go.mod h1:SoeejUwldiS7ZsyCBphOGURmWdwUFXs0J7TCjEhjKxM= -github.com/gobuffalo/packd v1.0.0 h1:6ERZvJHfe24rfFmA9OaoKBdC7+c9sydrytMg8SdFGBM= -github.com/gobuffalo/packd v1.0.0/go.mod h1:6VTc4htmJRFB7u1m/4LeMTWjFoYrUiBkU9Fdec9hrhI= -github.com/gobuffalo/plush/v4 v4.0.0 h1:ZHdmfr2R7DQ77XzWZK2PGKJOXm9NRy21EZ6Rw7FhuNw= -github.com/gobuffalo/plush/v4 v4.0.0/go.mod h1:ErFS3UxKqEb8fpFJT7lYErfN/Nw6vHGiDMTjxpk5bQ0= -github.com/gobuffalo/tags/v3 v3.0.2 h1:gxE6c6fA5radwQeg59aPIeYgCG8YA8AZd3Oh6fh5UXA= -github.com/gobuffalo/tags/v3 v3.0.2/go.mod h1:ZQeN6TCTiwAFnS0dNcbDtSgZDwNKSpqajvVtt6mlYpA= -github.com/gobuffalo/validate/v3 v3.0.0 h1:dF7Bg8NMF9Zv8bZvUMXYJXxZdj+eSZ8z/lGM7/jVFUE= +github.com/gobuffalo/github_flavored_markdown v1.1.1 h1:kUf8ginyBOTRXcKSTPsPAqlA25vQ80+xAspLIYaxmTU= +github.com/gobuffalo/github_flavored_markdown v1.1.1/go.mod h1:yU32Pen+eorS58oxh/bNZx76zUOCJwmvyV5FBrvzOKQ= +github.com/gobuffalo/helpers v0.6.2 h1:0caYR4GAtgZ/O0vTU2uyoMxtqRXUcKaIyRlRnw0GRgw= +github.com/gobuffalo/helpers v0.6.2/go.mod h1:wInbDi0vTJKZBviURTLRMFLE4+nF2uRuuL2fnlYo7w4= +github.com/gobuffalo/logger v1.0.6 h1:nnZNpxYo0zx+Aj9RfMPBm+x9zAU2OayFh/xrAWi34HU= +github.com/gobuffalo/logger v1.0.6/go.mod h1:J31TBEHR1QLV2683OXTAItYIg8pv2JMHnF/quuAbMjs= +github.com/gobuffalo/packd v1.0.1 h1:U2wXfRr4E9DH8IdsDLlRFwTZTK7hLfq9qT/QHXGVe/0= +github.com/gobuffalo/packd v1.0.1/go.mod h1:PP2POP3p3RXGz7Jh6eYEf93S7vA2za6xM7QT85L4+VY= +github.com/gobuffalo/plush/v4 v4.1.8 h1:0vJpTLPTc23iuyDEYftMgF6NYS24R8WryCAXl6kJZ/0= +github.com/gobuffalo/plush/v4 v4.1.8/go.mod h1:504Kpokbl1fT93Y6BtRoVmT+H+kWoqJsAaEDEe0HeNo= +github.com/gobuffalo/tags/v3 v3.1.0/go.mod h1:ZQeN6TCTiwAFnS0dNcbDtSgZDwNKSpqajvVtt6mlYpA= +github.com/gobuffalo/tags/v3 v3.1.1 h1:zXFBGckcXlJo83CF+czXD93VWrPeDMtETBvHAzXHW78= +github.com/gobuffalo/tags/v3 v3.1.1/go.mod h1:WdZd2T0qN77hOWnjpaZXTfDtAYm0CXoJr8n7rrekPZw= github.com/gobuffalo/validate/v3 v3.0.0/go.mod h1:HFpjq+AIiA2RHoQnQVTFKF/ZpUPXwyw82LgyDPxQ9r0= -github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= +github.com/gobuffalo/validate/v3 v3.3.0 h1:j++FFx9gtjTmIQeI9xlaIDZ0nV4x8YQZz4RJAlZNUxg= +github.com/gobuffalo/validate/v3 v3.3.0/go.mod h1:HFpjq+AIiA2RHoQnQVTFKF/ZpUPXwyw82LgyDPxQ9r0= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/gofrs/uuid v4.1.0+incompatible h1:sIa2eCvUTwgjbqXrPLfNwUf9S3i3mpH1O1atV+iL/Wk= +github.com/gofrs/uuid v4.1.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= +github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -32,64 +39,70 @@ github.com/markbates/oncer v1.0.0 h1:E83IaVAHygyndzPimgUYJjbshhDTALZyXxvk9FOlQRY github.com/markbates/oncer v1.0.0/go.mod h1:Z59JA581E9GP6w96jai+TGqafHPW+cPfRxz2aSZ0mcI= github.com/markbates/safe v1.0.1 h1:yjZkbvRM6IzKj9tlu/zMJLS0n/V351OZWRnF3QfaUxI= github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= -github.com/microcosm-cc/bluemonday v1.0.2 h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s= github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= +github.com/microcosm-cc/bluemonday v1.0.16 h1:kHmAq2t7WPWLjiGvzKa5o3HzSfahUKiOq7fAPUiMNIc= +github.com/microcosm-cc/bluemonday v1.0.16/go.mod h1:Z0r70sCuXHig8YpBzCc5eGHAap2K7e/u082ZUpDRRqM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.5.0 h1:1N5EYkVAPEywqZRJd7cwnRtCb6xJx7NH3T3WUTF980Q= -github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s+Squfpo= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= +github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d h1:yKm7XZV6j9Ev6lojP2XaIshpT4ymkqhMeSghO5Ps00E= github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e h1:qpG93cPwA5f7s/ZPBJnGOYQNK/vKsaDaseuKT5Asee8= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c h1:/nJuwDLoL/zrqY6gf57vxC+Pi+pZ8bfhpPkicO5H7W4= -golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0 h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b h1:0mm1VjtFUOIlE1SbDlwjYaDxZVDP2S5ou6y0gSgXHu8= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200323192200-8849913b6971 h1:7xTjEBkQgB1qdLZddETld2Flxf5D/U848jdOyhu39TE= -golang.org/x/tools v0.0.0-20200323192200-8849913b6971/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.1.7 h1:6j8CgantCy3yc8JGBqkDLMKWqZ0RDU2g1HVgacojGWQ= +golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 5d72ac3717c75eded5d941971816ddc4c37335ab Mon Sep 17 00:00:00 2001 From: Matthias Fasching Date: Tue, 16 Nov 2021 13:26:45 +0000 Subject: [PATCH 2/4] Fix linting errors --- .github/workflows/tests.yml | 30 +++++++++++++++++++++--------- disk.go | 7 +++++-- disk_test.go | 7 +++---- generator_test.go | 8 ++++---- gentest/files_test.go | 12 ++++++------ gentest/logger.go | 14 +++++++------- gentest/runner.go | 4 +++- gogen/files.go | 2 +- gogen/fmt_test.go | 4 +--- gogen/goimports/goimports.go | 5 ++++- gogen/templates.go | 1 - internal/testdata/bar/baz.txt | 2 +- internal/testdata/foo.txt | 2 +- internal/testdata/testdata.go | 13 +++++++++++++ runner.go | 11 ++++++++--- runner_test.go | 11 ++++++----- wet_runner.go | 4 +++- wet_runner_test.go | 2 +- 18 files changed, 88 insertions(+), 51 deletions(-) create mode 100644 internal/testdata/testdata.go diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f5e06f6..13cb13a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,19 +1,31 @@ name: Tests -on: [push] -jobs: +on: + push: + branches: + - master + pull_request: - tests-on: - name: ${{matrix.go-version}} ${{matrix.os}} +jobs: + tests-off: + name: ${{ matrix.os }} - ${{ matrix.go-version }} runs-on: ${{ matrix.os }} strategy: matrix: - go-version: [1.13.x, 1.14.x] - os: [macos-latest, windows-latest, ubuntu-latest] + go-version: + - "1.16.x" + - "1.17.x" + os: + - "macos-latest" + - "windows-latest" + - "ubuntu-latest" + steps: - - name: Checkout Code - uses: actions/checkout@v1 + - uses: actions/checkout@v2 + - name: Setup Go ${{ matrix.go }} + uses: actions/setup-go@v2 with: - fetch-depth: 1 + go-version: ${{ matrix.go-version }} + - name: Test run: | go mod tidy -v diff --git a/disk.go b/disk.go index f57e4a4..5f8ea74 100644 --- a/disk.go +++ b/disk.go @@ -55,7 +55,7 @@ func newDisk(r *Runner) *Disk { func (d *Disk) Remove(name string) { d.moot.Lock() defer d.moot.Unlock() - for f, _ := range d.files { + for f := range d.files { if strings.HasPrefix(f, name) { delete(d.files, f) } @@ -81,7 +81,10 @@ func (d *Disk) Find(name string) (File, error) { d.moot.RLock() if f, ok := d.files[name]; ok { if seek, ok := f.(io.Seeker); ok { - seek.Seek(0, 0) + _, err := seek.Seek(0, 0) + if err != nil { + return nil, err + } } d.moot.RUnlock() return f, nil diff --git a/disk_test.go b/disk_test.go index 5cdc811..4b8efdf 100644 --- a/disk_test.go +++ b/disk_test.go @@ -45,7 +45,7 @@ func Test_Disk_Delete(t *testing.T) { d := run.Disk d.Add(genny.NewFile("foo.txt", nil)) d.Add(genny.NewFile("bar.txt", nil)) - d.Delete("foo.txt") + r.NoError(d.Delete("foo.txt")) files := d.Files() r.Len(files, 1) @@ -111,10 +111,9 @@ func Test_Disk_AddBox(t *testing.T) { return err } p := strings.TrimPrefix(path, td+string(filepath.Separator)) - box.AddBytes(p, b) - - return nil + return box.AddBytes(p, b) }) + r.NoError(err) run := genny.DryRunner(context.Background()) d := run.Disk diff --git a/generator_test.go b/generator_test.go index 78f0506..c83d425 100644 --- a/generator_test.go +++ b/generator_test.go @@ -24,7 +24,7 @@ func Test_Generator_File(t *testing.T) { g.File(NewFile("foo.txt", strings.NewReader("hello"))) run := DryRunner(context.Background()) - run.With(g) + r.NoError(run.With(g)) r.NoError(run.Run()) res := run.Results() @@ -43,7 +43,7 @@ func Test_Generator_Box(t *testing.T) { r.NoError(g.Box(fixtures)) run := DryRunner(context.Background()) - run.With(g) + r.NoError(run.With(g)) r.NoError(run.Run()) res := run.Results() @@ -66,7 +66,7 @@ func Test_Command(t *testing.T) { g.Command(exec.Command("echo", "hello")) run := DryRunner(context.Background()) - run.With(g) + r.NoError(run.With(g)) r.NoError(run.Run()) res := run.Results() @@ -111,7 +111,7 @@ func Test_Merge(t *testing.T) { g1.Merge(g2) run := DryRunner(context.Background()) - run.With(g1) + r.NoError(run.With(g1)) r.NoError(run.Run()) res := run.Results() diff --git a/gentest/files_test.go b/gentest/files_test.go index 1750ae9..89e77dc 100644 --- a/gentest/files_test.go +++ b/gentest/files_test.go @@ -23,8 +23,8 @@ func Test_CompareBox(t *testing.T) { r := require.New(t) box := packd.NewMemoryBox() - box.AddString("a.html", "A") - box.AddString("b.html", "B") + r.NoError(box.AddString("a.html", "A")) + r.NoError(box.AddString("b.html", "B")) res := genny.Results{ Files: []genny.File{ @@ -40,8 +40,8 @@ func Test_CompareBox_Missing(t *testing.T) { r := require.New(t) box := packd.NewMemoryBox() - box.AddString("a.html", "A") - box.AddString("b.html", "B") + r.NoError(box.AddString("a.html", "A")) + r.NoError(box.AddString("b.html", "B")) res := genny.Results{ Files: []genny.File{ @@ -56,8 +56,8 @@ func Test_CompareBox_Stripped(t *testing.T) { r := require.New(t) box := packd.NewMemoryBox() - box.AddString("a.html", "A\nx") - box.AddString("b.html", "B") + r.NoError(box.AddString("a.html", "A\nx")) + r.NoError(box.AddString("b.html", "B")) res := genny.Results{ Files: []genny.File{ diff --git a/gentest/logger.go b/gentest/logger.go index f1ed816..cd31769 100644 --- a/gentest/logger.go +++ b/gentest/logger.go @@ -10,13 +10,13 @@ import ( ) const ( - DEBUG string = "DEBU" - INFO = "INFO" - WARN = "WARN" - ERROR = "ERRO" - FATAL = "FATA" - PANIC = "PANI" - PRINT = "PRIN" + DEBUG = "DEBU" + INFO = "INFO" + WARN = "WARN" + ERROR = "ERRO" + FATAL = "FATA" + PANIC = "PANI" + PRINT = "PRIN" ) // compile-time assertion to guarantee Logger conforms to genny.Logger diff --git a/gentest/runner.go b/gentest/runner.go index acbed18..928fd71 100644 --- a/gentest/runner.go +++ b/gentest/runner.go @@ -25,7 +25,9 @@ func RunNew(g *genny.Generator, err error) (genny.Results, error) { } r := NewRunner() - r.With(g) + if err := r.With(g); err != nil { + return genny.Results{}, err + } return sprint(r) } diff --git a/gogen/files.go b/gogen/files.go index 32ff1c9..ca0c378 100644 --- a/gogen/files.go +++ b/gogen/files.go @@ -30,5 +30,5 @@ func GoFiles(dir string) ([]string, error) { } return nil }) - return files, nil + return files, err } diff --git a/gogen/fmt_test.go b/gogen/fmt_test.go index e8154ec..4612212 100644 --- a/gogen/fmt_test.go +++ b/gogen/fmt_test.go @@ -16,10 +16,8 @@ func Test_GoFmt(t *testing.T) { g, err := Fmt("") r.NoError(err) - run.With(g) - + r.NoError(run.With(g)) r.NoError(run.Run()) - } func Test_FmtTransformer(t *testing.T) { diff --git a/gogen/goimports/goimports.go b/gogen/goimports/goimports.go index 45fef44..6b77392 100644 --- a/gogen/goimports/goimports.go +++ b/gogen/goimports/goimports.go @@ -67,7 +67,10 @@ func (r Runner) processFile(file File) error { } if bytes.Equal(src, res) { if s, ok := file.In.(io.Seeker); ok { - s.Seek(0, 0) + _, err := s.Seek(0, 0) + if err != nil { + return err + } } return nil } diff --git a/gogen/templates.go b/gogen/templates.go index 32b2b1e..8c5d462 100644 --- a/gogen/templates.go +++ b/gogen/templates.go @@ -45,7 +45,6 @@ func renderWithTemplate(f genny.File, data interface{}, helpers template.FuncMap var bb bytes.Buffer if err = t.Execute(&bb, data); err != nil { - err = err return f, err } return genny.StripExt(genny.NewFile(path, &bb), ".tmpl"), nil diff --git a/internal/testdata/bar/baz.txt b/internal/testdata/bar/baz.txt index ec46ee1..5858d48 100644 --- a/internal/testdata/bar/baz.txt +++ b/internal/testdata/bar/baz.txt @@ -1 +1 @@ -baz! +baz! \ No newline at end of file diff --git a/internal/testdata/foo.txt b/internal/testdata/foo.txt index 929efb3..a4d20dd 100644 --- a/internal/testdata/foo.txt +++ b/internal/testdata/foo.txt @@ -1 +1 @@ -foo! +foo! \ No newline at end of file diff --git a/internal/testdata/testdata.go b/internal/testdata/testdata.go new file mode 100644 index 0000000..8f613da --- /dev/null +++ b/internal/testdata/testdata.go @@ -0,0 +1,13 @@ +package testdata + +import ( + "embed" + "io/fs" +) + +//go:embed foo.txt bar/* +var testdata embed.FS + +func Data() fs.FS { + return testdata +} diff --git a/runner.go b/runner.go index 5119795..9b0fe78 100644 --- a/runner.go +++ b/runner.go @@ -32,7 +32,6 @@ type Runner struct { Root string // the root of the write path Disk *Disk steps map[string]*Step - generators []*Generator moot *sync.RWMutex results Results curGen *Generator @@ -225,7 +224,10 @@ func (r *Runner) File(f File) error { return e } if s, ok := f.(io.Seeker); ok { - s.Seek(0, 0) + _, err := s.Seek(0, 0) + if err != nil { + return err + } } return nil }) @@ -235,7 +237,10 @@ func (r *Runner) File(f File) error { } f = NewFile(f.Name(), f) if s, ok := f.(io.Seeker); ok { - s.Seek(0, 0) + _, err := s.Seek(0, 0) + if err != nil { + return err + } } r.Disk.Add(f) return nil diff --git a/runner_test.go b/runner_test.go index aa55560..2c13b15 100644 --- a/runner_test.go +++ b/runner_test.go @@ -23,8 +23,7 @@ func Test_Runner_Run(t *testing.T) { g.File(NewFile("foo.txt", strings.NewReader("Hello mark"))) run := DryRunner(context.Background()) - run.With(g) - + r.NoError(run.With(g)) r.NoError(run.Run()) res := run.Results() @@ -47,7 +46,7 @@ func Test_Runner_FindFile(t *testing.T) { g.File(NewFile("foo.txt", strings.NewReader("Hello world"))) run := DryRunner(context.Background()) - run.With(g) + r.NoError(run.With(g)) r.NoError(run.Run()) res := run.Results() @@ -140,7 +139,8 @@ func Test_Runner_FindStep(t *testing.T) { for i := 0; i < 3; i++ { s, err := NewStep(New(), i) r.NoError(err) - run.WithStep("step "+strconv.Itoa(i+1), s) + err = run.WithStep("step "+strconv.Itoa(i+1), s) + r.NoError(err) } s, err := run.FindStep("step 2") @@ -158,7 +158,8 @@ func Test_Runner_ReplaceStep(t *testing.T) { g.File(NewFileS(fmt.Sprintf("%d.txt", i), strconv.Itoa(i))) s, err := NewStep(g, i) r.NoError(err) - run.WithStep("step "+strconv.Itoa(i), s) + err = run.WithStep("step "+strconv.Itoa(i), s) + r.NoError(err) } gx := New() diff --git a/wet_runner.go b/wet_runner.go index a3825b6..170d0f9 100644 --- a/wet_runner.go +++ b/wet_runner.go @@ -29,7 +29,9 @@ func WetRunner(ctx context.Context) *Runner { r.ChdirFn = func(path string, fn func() error) error { pwd, _ := os.Getwd() defer os.Chdir(pwd) - os.MkdirAll(path, 0755) + if err := os.MkdirAll(path, 0755); err != nil { + return err + } if err := os.Chdir(path); err != nil { return err } diff --git a/wet_runner_test.go b/wet_runner_test.go index 2c698c2..e5b04ff 100644 --- a/wet_runner_test.go +++ b/wet_runner_test.go @@ -26,7 +26,7 @@ func Test_WetRunner(t *testing.T) { g.File(NewFile("foo.txt", strings.NewReader("foo!"))) dp := filepath.Join("a", "b", "c") g.File(NewDir(dp, 0755)) - run.With(g) + r.NoError(run.With(g)) r.NoError(run.Run()) From e46c27cdde0a98ac6117b869bc65377394bd53da Mon Sep 17 00:00:00 2001 From: Matthias Fasching Date: Tue, 16 Nov 2021 13:27:02 +0000 Subject: [PATCH 3/4] Add FS to generator as alternative to Box --- generator.go | 18 ++++++++++++++++++ generator_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/generator.go b/generator.go index ef15cee..549bcd3 100644 --- a/generator.go +++ b/generator.go @@ -1,6 +1,7 @@ package genny import ( + "io/fs" "math/rand" "os/exec" "sync" @@ -79,6 +80,23 @@ func (g *Generator) Box(box packd.Walker) error { }) } +func (g *Generator) FS(fsys fs.FS) error { + return fs.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d.IsDir() { + return nil + } + f, err := fsys.Open(path) + if err != nil { + return err + } + g.File(NewFile(path, f)) + return nil + }) +} + // RunFn adds a generic "runner" function to the generator. func (g *Generator) RunFn(fn RunFn) { g.moot.Lock() diff --git a/generator_test.go b/generator_test.go index c83d425..3433e7a 100644 --- a/generator_test.go +++ b/generator_test.go @@ -6,6 +6,7 @@ import ( "strings" "testing" + "github.com/gobuffalo/genny/v2/internal/testdata" "github.com/gobuffalo/packd" "github.com/stretchr/testify/require" ) @@ -59,6 +60,29 @@ func Test_Generator_Box(t *testing.T) { r.Equal("foo!", f.String()) } +func Test_Generator_FS(t *testing.T) { + r := require.New(t) + + g := New() + r.NoError(g.FS(testdata.Data())) + + run := DryRunner(context.Background()) + r.NoError(run.With(g)) + r.NoError(run.Run()) + + res := run.Results() + r.Len(res.Commands, 0) + r.Len(res.Files, 2) + + f := res.Files[0] + r.Equal("bar/baz.txt", f.Name()) + r.Equal("baz!", f.String()) + + f = res.Files[1] + r.Equal("foo.txt", f.Name()) + r.Equal("foo!", f.String()) +} + func Test_Command(t *testing.T) { r := require.New(t) From 94c7662ac05b77412630443c90a9043ddef045e9 Mon Sep 17 00:00:00 2001 From: Matthias Fasching Date: Tue, 16 Nov 2021 13:58:08 +0000 Subject: [PATCH 4/4] Add more FS methods --- disk.go | 19 +++++++++ disk_test.go | 18 ++++++++ force.go | 25 ++++++++++++ generator.go | 1 + gentest/files.go | 77 ++++++++++++++++++++++++++++++++++- gentest/files_test.go | 39 ++++++++++++++++++ internal/testdata/a.html | 1 + internal/testdata/b.html | 1 + internal/testdata/testdata.go | 7 ++++ 9 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 internal/testdata/a.html create mode 100644 internal/testdata/b.html diff --git a/disk.go b/disk.go index 5f8ea74..3221c21 100644 --- a/disk.go +++ b/disk.go @@ -3,6 +3,7 @@ package genny import ( "bytes" "io" + "io/fs" "os" "runtime" "sort" @@ -28,6 +29,24 @@ func (d *Disk) AddBox(box packd.Walker) error { }) } +func (d *Disk) AddFS(fsys fs.FS) error { + return fs.WalkDir(fsys, ".", func(path string, dir fs.DirEntry, err error) error { + if err != nil { + return err + } + if dir.IsDir() { + return nil + } + + file, err := fsys.Open(path) + if err != nil { + return err + } + d.Add(NewFile(path, file)) + return nil + }) +} + // Files returns a sorted list of all the files in the disk func (d *Disk) Files() []File { var files []File diff --git a/disk_test.go b/disk_test.go index 4b8efdf..33c37a0 100644 --- a/disk_test.go +++ b/disk_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/gobuffalo/genny/v2" + "github.com/gobuffalo/genny/v2/internal/testdata" "github.com/gobuffalo/packd" "github.com/stretchr/testify/require" ) @@ -128,3 +129,20 @@ func Test_Disk_AddBox(t *testing.T) { r.NoError(err) r.Equal("bar/baz.txt", f.Name()) } + +func Test_Disk_AddFS(t *testing.T) { + r := require.New(t) + + run := genny.DryRunner(context.Background()) + d := run.Disk + err := d.AddFS(testdata.Data()) + r.NoError(err) + + f, err := d.Find("foo.txt") + r.NoError(err) + r.Equal("foo.txt", f.Name()) + + f, err = d.Find("bar/baz.txt") + r.NoError(err) + r.Equal("bar/baz.txt", f.Name()) +} diff --git a/force.go b/force.go index f7790c1..a99ed99 100644 --- a/force.go +++ b/force.go @@ -2,6 +2,7 @@ package genny import ( "fmt" + "io/fs" "io/ioutil" "os" "path/filepath" @@ -23,6 +24,30 @@ func ForceBox(g *Generator, box packd.Walker, force bool) error { }) } +// ForceFS will mount each file in the fs.FS and wrap it with ForceFile +func ForceFS(g *Generator, fsys fs.FS, force bool) error { + return fs.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d.IsDir() { + return nil + } + r, err := fsys.Open(path) + if err != nil { + return err + } + f := NewFile(path, r) + ff := ForceFile(f, force) + f, err = ff(f) + if err != nil { + return err + } + g.File(f) + return nil + }) +} + // ForceFile is a TransformerFn that will return an error if the path exists if `force` is false. If `force` is true it will delete the path. func ForceFile(f File, force bool) TransformerFn { return func(f File) (File, error) { diff --git a/generator.go b/generator.go index 549bcd3..6815f2b 100644 --- a/generator.go +++ b/generator.go @@ -80,6 +80,7 @@ func (g *Generator) Box(box packd.Walker) error { }) } +// FS walks through a fs.FS and adds Files for each entry. func (g *Generator) FS(fsys fs.FS) error { return fs.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error { if err != nil { diff --git a/gentest/files.go b/gentest/files.go index 2654576..f8ac639 100644 --- a/gentest/files.go +++ b/gentest/files.go @@ -2,6 +2,8 @@ package gentest import ( "fmt" + "io/fs" + "io/ioutil" "path/filepath" "sort" "strings" @@ -35,7 +37,7 @@ func CompareFiles(exp []string, act []genny.File) error { } // CompareBox compares a packd.Walkable box of files (usually fixtures) -// the results of a genny.Runner +// to the results of a genny.Runner func CompareBox(exp packd.Walkable, res genny.Results) error { return exp.Walk(func(path string, file packd.File) error { if filepath.Base(path) == ".DS_Store" { @@ -52,6 +54,43 @@ func CompareBox(exp packd.Walkable, res genny.Results) error { }) } +// CompareFS compares a fs.FS of files (usually fixtures) to the results +// of a genny.Runner +func CompareFS(exp fs.FS, res genny.Results) error { + return fs.WalkDir(exp, ".", func(path string, d fs.DirEntry, err error) error { + if filepath.Base(path) == ".DS_Store" { + return nil + } + + if err != nil { + return err + } + if d.IsDir() { + return nil + } + + f, err := res.Find(path) + if err != nil { + return err + } + + file, err := exp.Open(path) + if err != nil { + return err + } + b, err := ioutil.ReadAll(file) + if err != nil { + return err + } + + if string(b) != f.String() { + return fmt.Errorf("[%s] expected %s to match %s", path, string(b), f) + } + + return nil + }) +} + // CompareBoxStripped compares a packd.Walkable box of files (usually fixtures) // the results of a genny.Runner by removing any whitespaces, tabs, or newlines. func CompareBoxStripped(exp packd.Walkable, res genny.Results) error { @@ -70,6 +109,42 @@ func CompareBoxStripped(exp packd.Walkable, res genny.Results) error { }) } +// CompareFSStripped compares a fs.FS (usually fixtures) to the results of a +// genny.Runner by removing any whitespaces, tabs, or newlines. +func CompareFSStripped(exp fs.FS, res genny.Results) error { + return fs.WalkDir(exp, ".", func(path string, d fs.DirEntry, err error) error { + if filepath.Base(path) == ".DS_Store" { + return nil + } + + if err != nil { + return err + } + if d.IsDir() { + return nil + } + + f, err := res.Find(path) + if err != nil { + return err + } + + file, err := exp.Open(path) + if err != nil { + return err + } + b, err := ioutil.ReadAll(file) + if err != nil { + return err + } + + if clean(string(b)) != clean(f.String()) { + return fmt.Errorf("[%s] expected %s to match %s", path, file, f) + } + return nil + }) +} + func clean(s string) string { s = strings.TrimSpace(s) s = strings.Replace(s, "\n", "", -1) diff --git a/gentest/files_test.go b/gentest/files_test.go index 89e77dc..3997c97 100644 --- a/gentest/files_test.go +++ b/gentest/files_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/gobuffalo/genny/v2" + "github.com/gobuffalo/genny/v2/internal/testdata" "github.com/gobuffalo/packd" "github.com/stretchr/testify/require" ) @@ -68,3 +69,41 @@ func Test_CompareBox_Stripped(t *testing.T) { r.NoError(CompareBoxStripped(box, res)) } + +func Test_CompareFS(t *testing.T) { + r := require.New(t) + + res := genny.Results{ + Files: []genny.File{ + genny.NewFileS("a.html", "A"), + genny.NewFileS("b.html", "B"), + }, + } + + r.NoError(CompareFS(testdata.BoxData(), res)) +} + +func Test_CompareFS_Missing(t *testing.T) { + r := require.New(t) + + res := genny.Results{ + Files: []genny.File{ + genny.NewFileS("b.html", "b"), + }, + } + + r.Error(CompareFS(testdata.BoxData(), res)) +} + +func Test_CompareFS_Stripped(t *testing.T) { + r := require.New(t) + + res := genny.Results{ + Files: []genny.File{ + genny.NewFileS("a.html", " A\n\r"), + genny.NewFileS("b.html", "B"), + }, + } + + r.NoError(CompareFSStripped(testdata.BoxData(), res)) +} diff --git a/internal/testdata/a.html b/internal/testdata/a.html new file mode 100644 index 0000000..8c7e5a6 --- /dev/null +++ b/internal/testdata/a.html @@ -0,0 +1 @@ +A \ No newline at end of file diff --git a/internal/testdata/b.html b/internal/testdata/b.html new file mode 100644 index 0000000..7371f47 --- /dev/null +++ b/internal/testdata/b.html @@ -0,0 +1 @@ +B \ No newline at end of file diff --git a/internal/testdata/testdata.go b/internal/testdata/testdata.go index 8f613da..f5fdcc7 100644 --- a/internal/testdata/testdata.go +++ b/internal/testdata/testdata.go @@ -11,3 +11,10 @@ var testdata embed.FS func Data() fs.FS { return testdata } + +//go:embed a.html b.html +var boxdata embed.FS + +func BoxData() fs.FS { + return boxdata +}