mirror of
https://github.com/dnote/dnote
synced 2026-03-14 14:35:50 +01:00
Upgrade go and dependencies (#679)
This commit is contained in:
parent
a26037f83a
commit
5928f9619f
43 changed files with 529 additions and 476 deletions
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
|
|
@ -31,10 +31,10 @@ jobs:
|
|||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/setup-go@v6
|
||||
with:
|
||||
go-version: '1.21.0'
|
||||
go-version: '>=1.25.0'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
|
|
|
|||
44
go.mod
44
go.mod
|
|
@ -1,49 +1,53 @@
|
|||
module github.com/dnote/dnote
|
||||
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.6
|
||||
go 1.25
|
||||
|
||||
require (
|
||||
github.com/aymerick/douceur v0.2.0
|
||||
github.com/dnote/actions v0.2.0
|
||||
github.com/fatih/color v1.15.0
|
||||
github.com/google/go-cmp v0.6.0
|
||||
github.com/fatih/color v1.18.0
|
||||
github.com/google/go-cmp v0.7.0
|
||||
github.com/google/go-github v17.0.0+incompatible
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/gorilla/csrf v1.7.2
|
||||
github.com/gorilla/csrf v1.7.3
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/gorilla/schema v1.2.1
|
||||
github.com/jinzhu/gorm v1.9.16
|
||||
github.com/gorilla/schema v1.4.1
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/lib/pq v1.10.9
|
||||
github.com/mattn/go-sqlite3 v1.14.20
|
||||
github.com/mattn/go-sqlite3 v1.14.32
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/robfig/cron v1.2.0
|
||||
github.com/rubenv/sql-migrate v1.6.1
|
||||
github.com/rubenv/sql-migrate v1.8.0
|
||||
github.com/sergi/go-diff v1.3.1
|
||||
github.com/spf13/cobra v1.8.0
|
||||
golang.org/x/crypto v0.21.0
|
||||
golang.org/x/time v0.5.0
|
||||
github.com/spf13/cobra v1.10.1
|
||||
golang.org/x/crypto v0.42.0
|
||||
golang.org/x/time v0.13.0
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gorm.io/driver/postgres v1.5.7
|
||||
gorm.io/gorm v1.25.7
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/PuerkitoBio/goquery v1.8.1 // indirect
|
||||
github.com/andybalholm/cascadia v1.3.2 // indirect
|
||||
github.com/PuerkitoBio/goquery v1.10.3 // indirect
|
||||
github.com/andybalholm/cascadia v1.3.3 // indirect
|
||||
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/gorilla/css v1.0.1 // indirect
|
||||
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||
github.com/jackc/pgx/v5 v5.4.3 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
golang.org/x/net v0.23.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
golang.org/x/term v0.18.0 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
golang.org/x/net v0.44.0 // indirect
|
||||
golang.org/x/sys v0.36.0 // indirect
|
||||
golang.org/x/term v0.35.0 // indirect
|
||||
golang.org/x/text v0.29.0 // indirect
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
)
|
||||
|
|
|
|||
154
go.sum
154
go.sum
|
|
@ -1,35 +1,25 @@
|
|||
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
|
||||
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
|
||||
github.com/PuerkitoBio/goquery v1.8.1/go.mod h1:Q8ICL1kNUJ2sXGoAhPGUdYDJvgQgHzJsnnd3H7Ho5jQ=
|
||||
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
|
||||
github.com/andybalholm/cascadia v1.3.1/go.mod h1:R4bJ1UQfqADjvDa4P6HZHLh/3OxWWEqc0Sk8XGwHqvA=
|
||||
github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
|
||||
github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
|
||||
github.com/PuerkitoBio/goquery v1.10.3 h1:pFYcNSqHxBD06Fpj/KsbStFRsgRATgnf3LeXiUkhzPo=
|
||||
github.com/PuerkitoBio/goquery v1.10.3/go.mod h1:tMUX0zDMHXYlAQk6p35XxQMqMweEKB7iK7iLNd4RH4Y=
|
||||
github.com/andybalholm/cascadia v1.3.3 h1:AG2YHrzJIm4BZ19iwJ/DAua6Btl3IwJX+VI4kktS1LM=
|
||||
github.com/andybalholm/cascadia v1.3.3/go.mod h1:xNd9bqTn98Ln4DwST8/nG+H0yuB8Hmgu1YHNnWw0GeA=
|
||||
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/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
|
||||
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/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/denisenkom/go-mssqldb v0.9.0 h1:RSohk2RsiZqLZ0zCjtfn3S4Gp4exhpBWHyQ7D0yGjAk=
|
||||
github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/dnote/actions v0.2.0 h1:P1ut2/QRKwfAzIIB374vN9A4IanU94C/payEocvngYo=
|
||||
github.com/dnote/actions v0.2.0/go.mod h1:bBIassLhppVQdbC3iaE92SHBpM1HOVe+xZoAlj9ROxw=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DPaBjB8zlTR87/ElzFsnQfuHnVUVqpZZIcV5Y=
|
||||
github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0=
|
||||
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
|
||||
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
|
||||
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||
github.com/go-gorp/gorp/v3 v3.1.0 h1:ItKF/Vbuj31dmV4jxA1qblpSwkl9g1typ24xoe70IGs=
|
||||
github.com/go-gorp/gorp/v3 v3.1.0/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpjH8TixEw=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
|
||||
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
|
|
@ -38,24 +28,28 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
|
|||
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/csrf v1.7.2 h1:oTUjx0vyf2T+wkrx09Trsev1TE+/EbDAeHtSTbtC2eI=
|
||||
github.com/gorilla/csrf v1.7.2/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk=
|
||||
github.com/gorilla/csrf v1.7.3 h1:BHWt6FTLZAb2HtWT5KDBf6qgpZzvtbp9QWDRKZMXJC0=
|
||||
github.com/gorilla/csrf v1.7.3/go.mod h1:F1Fj3KG23WYHE6gozCmBAezKookxbIvUJT+121wTuLk=
|
||||
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
|
||||
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
|
||||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
|
||||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
|
||||
github.com/gorilla/schema v1.2.1 h1:tjDxcmdb+siIqkTNoV+qRH2mjYdr2hHe5MKXbp61ziM=
|
||||
github.com/gorilla/schema v1.2.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
|
||||
github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E=
|
||||
github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
|
||||
github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA=
|
||||
github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
|
||||
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.4.3 h1:cxFyXhxlvAifxnkKKdlxv8XqUf59tDlYjnV5YYfsJJY=
|
||||
github.com/jackc/pgx/v5 v5.4.3/go.mod h1:Ig06C2Vu0t5qXC60W8sqIthScaEnFvojjj9dSljmHRA=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
|
||||
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
|
|
@ -65,17 +59,14 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
|||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
|
||||
github.com/mattn/go-sqlite3 v1.14.20 h1:BAZ50Ns0OFBNxdAqFhbZqdPcht1Xlb16pDCqkq1spr0=
|
||||
github.com/mattn/go-sqlite3 v1.14.20/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs=
|
||||
github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
|
|
@ -88,76 +79,98 @@ github.com/robfig/cron v1.2.0 h1:ZjScXvvxeQ63Dbyxy76Fj3AT3Ut0aKsyd2/tl3DTMuQ=
|
|||
github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfmt2k=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||
github.com/rubenv/sql-migrate v1.6.1 h1:bo6/sjsan9HaXAsNxYP/jCEDUGibHp8JmOBw7NTGRos=
|
||||
github.com/rubenv/sql-migrate v1.6.1/go.mod h1:tPzespupJS0jacLfhbwto/UjSX+8h2FdWB7ar+QlHa0=
|
||||
github.com/rubenv/sql-migrate v1.8.0 h1:dXnYiJk9k3wetp7GfQbKJcPHjVJL6YK19tKj8t2Ns0o=
|
||||
github.com/rubenv/sql-migrate v1.8.0/go.mod h1:F2bGFBwCU+pnmbtNYDeKvSuvL6lBVtXDXUUv5t+u1qw=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
||||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
|
||||
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
|
||||
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
|
||||
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
|
||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
|
||||
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
|
||||
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
|
||||
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
|
||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
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-20200323222414-85ca7c5b95cd/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-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
|
||||
golang.org/x/sys v0.36.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
|
||||
golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8=
|
||||
golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/term v0.35.0 h1:bZBVKBudEyhRcajGcNc3jIfWPqV4y/Kt2XcoigOWtDQ=
|
||||
golang.org/x/term v0.35.0/go.mod h1:TPGtkTLesOwf2DE8CgVYiZinHAOuy5AYUYT1lENIZnA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
|
||||
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
|
||||
golang.org/x/time v0.13.0 h1:eUlYslOIt32DgYD6utsuUeHs4d7AsEYLuIAdg7FlYgI=
|
||||
golang.org/x/time v0.13.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
|
||||
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.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||
|
|
@ -171,5 +184,10 @@ gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkp
|
|||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/postgres v1.5.7 h1:8ptbNJTDbEmhdr62uReG5BGkdQyeasu/FZHxI0IMGnM=
|
||||
gorm.io/driver/postgres v1.5.7/go.mod h1:3e019WlBaYI5o5LIdNV+LyxCMNtLOQETBXL2h4chKpA=
|
||||
gorm.io/gorm v1.25.7 h1:VsD6acwRjz2zFxGO50gPO6AkNs7KKnvfzUjHQhZDz/A=
|
||||
gorm.io/gorm v1.25.7/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func TestSignIn(t *testing.T) {
|
|||
|
||||
err := json.NewDecoder(r.Body).Decode(&payload)
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||
t.Fatal(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func TestProcessFragments(t *testing.T) {
|
|||
// exec
|
||||
sl, err := processFragments(fragments)
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
expected := syncList{
|
||||
|
|
@ -113,12 +113,12 @@ func TestGetLastSyncAt(t *testing.T) {
|
|||
// exec
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
got, err := getLastSyncAt(tx)
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "getting last_sync_at").Error())
|
||||
t.Fatal(errors.Wrap(err, "getting last_sync_at").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -136,12 +136,12 @@ func TestGetLastMaxUSN(t *testing.T) {
|
|||
// exec
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
got, err := getLastMaxUSN(tx)
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "getting last_max_usn").Error())
|
||||
t.Fatal(errors.Wrap(err, "getting last_max_usn").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -189,12 +189,12 @@ func TestResolveLabel(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
got, err := resolveLabel(tx, tc.input)
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
tx.Rollback()
|
||||
|
||||
|
|
@ -212,12 +212,12 @@ func TestSyncDeleteNote(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := syncDeleteNote(tx, "nonexistent-note-uuid"); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -254,12 +254,12 @@ func TestSyncDeleteNote(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction for test case").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction for test case").Error())
|
||||
}
|
||||
|
||||
if err := syncDeleteNote(tx, "n1-uuid"); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -324,12 +324,12 @@ func TestSyncDeleteNote(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction for test case").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction for test case").Error())
|
||||
}
|
||||
|
||||
if err := syncDeleteNote(tx, "n1-uuid"); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -373,12 +373,12 @@ func TestSyncDeleteBook(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := syncDeleteBook(tx, "nonexistent-book-uuid"); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -424,12 +424,12 @@ func TestSyncDeleteBook(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction for test case").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction for test case").Error())
|
||||
}
|
||||
|
||||
if err := syncDeleteBook(tx, b1UUID); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -492,12 +492,12 @@ func TestSyncDeleteBook(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction for test case").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction for test case").Error())
|
||||
}
|
||||
|
||||
if err := syncDeleteBook(tx, b1UUID); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -547,12 +547,12 @@ func TestSyncDeleteBook(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction for test case").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction for test case").Error())
|
||||
}
|
||||
|
||||
if err := syncDeleteBook(tx, b1UUID); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -599,7 +599,7 @@ func TestFullSyncNote(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
n := client.SyncFragNote{
|
||||
|
|
@ -614,7 +614,7 @@ func TestFullSyncNote(t *testing.T) {
|
|||
|
||||
if err := fullSyncNote(tx, n); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -834,7 +834,7 @@ n1 body edited
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
// update all fields but uuid and bump usn
|
||||
|
|
@ -850,7 +850,7 @@ n1 body edited
|
|||
|
||||
if err := fullSyncNote(tx, n); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -893,7 +893,7 @@ func TestFullSyncBook(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
b2UUID := testutils.MustGenerateUUID(t)
|
||||
|
|
@ -907,7 +907,7 @@ func TestFullSyncBook(t *testing.T) {
|
|||
|
||||
if err := fullSyncBook(tx, b); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1032,7 +1032,7 @@ func TestFullSyncBook(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
// update all fields but uuid and bump usn
|
||||
|
|
@ -1045,7 +1045,7 @@ func TestFullSyncBook(t *testing.T) {
|
|||
|
||||
if err := fullSyncBook(tx, b); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1085,7 +1085,7 @@ func TestStepSyncNote(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
n := client.SyncFragNote{
|
||||
|
|
@ -1100,7 +1100,7 @@ func TestStepSyncNote(t *testing.T) {
|
|||
|
||||
if err := stepSyncNote(tx, n); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1246,7 +1246,7 @@ n1 body edited
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
// update all fields but uuid and bump usn
|
||||
|
|
@ -1262,7 +1262,7 @@ n1 body edited
|
|||
|
||||
if err := stepSyncNote(tx, n); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1305,7 +1305,7 @@ func TestStepSyncBook(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
b2UUID := testutils.MustGenerateUUID(t)
|
||||
|
|
@ -1319,7 +1319,7 @@ func TestStepSyncBook(t *testing.T) {
|
|||
|
||||
if err := stepSyncBook(tx, b); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1430,7 +1430,7 @@ func TestStepSyncBook(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
// update all fields but uuid and bump usn
|
||||
|
|
@ -1443,7 +1443,7 @@ func TestStepSyncBook(t *testing.T) {
|
|||
|
||||
if err := fullSyncBook(tx, b); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1489,7 +1489,7 @@ func TestMergeBook(t *testing.T) {
|
|||
// test
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
b1 := client.SyncFragBook{
|
||||
|
|
@ -1502,7 +1502,7 @@ func TestMergeBook(t *testing.T) {
|
|||
|
||||
if err := mergeBook(tx, b1, modeInsert); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1534,7 +1534,7 @@ func TestMergeBook(t *testing.T) {
|
|||
// test
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
b := client.SyncFragBook{
|
||||
|
|
@ -1547,7 +1547,7 @@ func TestMergeBook(t *testing.T) {
|
|||
|
||||
if err := mergeBook(tx, b, modeInsert); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1589,7 +1589,7 @@ func TestMergeBook(t *testing.T) {
|
|||
// test
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
b := client.SyncFragBook{
|
||||
|
|
@ -1602,7 +1602,7 @@ func TestMergeBook(t *testing.T) {
|
|||
|
||||
if err := mergeBook(tx, b, modeInsert); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1654,7 +1654,7 @@ func TestMergeBook(t *testing.T) {
|
|||
// test
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
b1UUID := testutils.MustGenerateUUID(t)
|
||||
|
|
@ -1670,7 +1670,7 @@ func TestMergeBook(t *testing.T) {
|
|||
|
||||
if err := mergeBook(tx, b1, modeUpdate); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1704,7 +1704,7 @@ func TestMergeBook(t *testing.T) {
|
|||
// test
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
b := client.SyncFragBook{
|
||||
|
|
@ -1717,7 +1717,7 @@ func TestMergeBook(t *testing.T) {
|
|||
|
||||
if err := mergeBook(tx, b, modeUpdate); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1760,7 +1760,7 @@ func TestMergeBook(t *testing.T) {
|
|||
// test
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
b := client.SyncFragBook{
|
||||
|
|
@ -1773,7 +1773,7 @@ func TestMergeBook(t *testing.T) {
|
|||
|
||||
if err := mergeBook(tx, b, modeUpdate); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1832,7 +1832,7 @@ func TestSaveServerState(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
serverTime := int64(1541108743)
|
||||
|
|
@ -1841,7 +1841,7 @@ func TestSaveServerState(t *testing.T) {
|
|||
err = saveSyncState(tx, serverTime, serverMaxUSN)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -1907,7 +1907,7 @@ func TestSendBooks(t *testing.T) {
|
|||
|
||||
err := json.NewDecoder(r.Body).Decode(&payload)
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||
t.Fatal(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1955,12 +1955,12 @@ func TestSendBooks(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if _, err := sendBooks(ctx, tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2026,7 +2026,7 @@ func TestSendBooks_isBehind(t *testing.T) {
|
|||
|
||||
err := json.NewDecoder(r.Body).Decode(&payload)
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||
t.Fatal(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -2110,13 +2110,13 @@ func TestSendBooks_isBehind(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
isBehind, err := sendBooks(ctx, tx)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2158,13 +2158,13 @@ func TestSendBooks_isBehind(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
isBehind, err := sendBooks(ctx, tx)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2206,13 +2206,13 @@ func TestSendBooks_isBehind(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
isBehind, err := sendBooks(ctx, tx)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2271,7 +2271,7 @@ func TestSendNotes(t *testing.T) {
|
|||
|
||||
err := json.NewDecoder(r.Body).Decode(&payload)
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||
t.Fatal(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -2319,12 +2319,12 @@ func TestSendNotes(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if _, err := sendNotes(ctx, tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2419,12 +2419,12 @@ func TestSendNotes_addedOn(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if _, err := sendNotes(ctx, tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2442,7 +2442,7 @@ func TestSendNotes_isBehind(t *testing.T) {
|
|||
|
||||
err := json.NewDecoder(r.Body).Decode(&payload)
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||
t.Fatal(errors.Wrap(err, "decoding payload in the test server").Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -2527,13 +2527,13 @@ func TestSendNotes_isBehind(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
isBehind, err := sendNotes(ctx, tx)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2576,13 +2576,13 @@ func TestSendNotes_isBehind(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
isBehind, err := sendNotes(ctx, tx)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2625,13 +2625,13 @@ func TestSendNotes_isBehind(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
isBehind, err := sendNotes(ctx, tx)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2789,7 +2789,7 @@ n1 body edited
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
// update all fields but uuid and bump usn
|
||||
|
|
@ -2809,7 +2809,7 @@ n1 body edited
|
|||
|
||||
if err := mergeNote(tx, fragNote, localNote); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2874,12 +2874,12 @@ func TestCheckBookPristine(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
got, err := checkNotesPristine(tx, "b1-uuid")
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -2892,12 +2892,12 @@ func TestCheckBookPristine(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
got, err := checkNotesPristine(tx, "b2-uuid")
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -3082,12 +3082,12 @@ func TestCleanLocalNotes(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := cleanLocalNotes(tx, &list); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -3150,12 +3150,12 @@ func TestCleanLocalBooks(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := cleanLocalBooks(tx, &list); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ func checkLegacyPath(ctx context.DnoteCtx) (string, bool) {
|
|||
|
||||
ok, err := utils.FileExists(legacyPath)
|
||||
if err != nil {
|
||||
log.Errorf(errors.Wrapf(err, "checking legacy dnote directory at %s", legacyPath).Error())
|
||||
log.Error(errors.Wrapf(err, "checking legacy dnote directory at %s", legacyPath).Error())
|
||||
}
|
||||
if ok {
|
||||
return legacyPath, true
|
||||
|
|
|
|||
|
|
@ -134,12 +134,12 @@ func TestNoteInsert(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
if err := n.Insert(tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -294,7 +294,7 @@ func TestNoteUpdate(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
n1.BookUUID = tc.newBookUUID
|
||||
|
|
@ -307,7 +307,7 @@ func TestNoteUpdate(t *testing.T) {
|
|||
|
||||
if err := n1.Update(tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -387,11 +387,11 @@ func TestNoteUpdateUUID(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
if err := n1.UpdateUUID(tx, tc.newUUID); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -446,12 +446,12 @@ func TestNoteExpunge(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := n1.Expunge(tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -555,12 +555,12 @@ func TestBookInsert(t *testing.T) {
|
|||
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
if err := b.Insert(tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -645,7 +645,7 @@ func TestBookUpdate(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("beginning a transaction for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
b1.Label = tc.newLabel
|
||||
|
|
@ -655,7 +655,7 @@ func TestBookUpdate(t *testing.T) {
|
|||
|
||||
if err := b1.Update(tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
t.Fatal(errors.Wrap(err, fmt.Sprintf("executing for test case %d", idx)).Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -724,11 +724,11 @@ func TestBookUpdateUUID(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
if err := b1.UpdateUUID(tx, tc.newUUID); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -775,12 +775,12 @@ func TestBookExpunge(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := b1.Expunge(tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -824,12 +824,12 @@ func TestNoteFTS(t *testing.T) {
|
|||
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := n.Insert(tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "inserting").Error())
|
||||
t.Fatal(errors.Wrap(err, "inserting").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -847,13 +847,13 @@ func TestNoteFTS(t *testing.T) {
|
|||
// execute - update
|
||||
tx, err = db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
n.Body = "baz quz"
|
||||
if err := n.Update(tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "updating").Error())
|
||||
t.Fatal(errors.Wrap(err, "updating").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -872,12 +872,12 @@ func TestNoteFTS(t *testing.T) {
|
|||
// execute - delete
|
||||
tx, err = db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := n.Expunge(tx); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "expunging").Error())
|
||||
t.Fatal(errors.Wrap(err, "expunging").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
|
|||
|
|
@ -53,12 +53,12 @@ func TestInsertSystem(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := InsertSystem(tx, tc.key, tc.val); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing for test case").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing for test case").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -106,12 +106,12 @@ func TestUpsertSystem(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := UpsertSystem(tx, tc.key, tc.val); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing for test case").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing for test case").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -142,12 +142,12 @@ func TestGetSystem(t *testing.T) {
|
|||
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
var dest string
|
||||
if err := GetSystem(tx, "foo", &dest); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing for test case").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing for test case").Error())
|
||||
}
|
||||
tx.Commit()
|
||||
|
||||
|
|
@ -165,12 +165,12 @@ func TestGetSystem(t *testing.T) {
|
|||
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
var dest int64
|
||||
if err := GetSystem(tx, "foo", &dest); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing for test case").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing for test case").Error())
|
||||
}
|
||||
tx.Commit()
|
||||
|
||||
|
|
@ -210,12 +210,12 @@ func TestUpdateSystem(t *testing.T) {
|
|||
// execute
|
||||
tx, err := db.Begin()
|
||||
if err != nil {
|
||||
t.Fatalf(errors.Wrap(err, "beginning a transaction").Error())
|
||||
t.Fatal(errors.Wrap(err, "beginning a transaction").Error())
|
||||
}
|
||||
|
||||
if err := UpdateSystem(tx, tc.key, tc.val); err != nil {
|
||||
tx.Rollback()
|
||||
t.Fatalf(errors.Wrap(err, "executing for test case").Error())
|
||||
t.Fatal(errors.Wrap(err, "executing for test case").Error())
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func checkLegacyDBPath() (string, bool) {
|
|||
}
|
||||
|
||||
if err != nil {
|
||||
log.Errorf(errors.Wrapf(err, "checking legacy dnote directory at %s", legacyDnoteDir).Error())
|
||||
log.Error(errors.Wrapf(err, "checking legacy dnote directory at %s", legacyDnoteDir).Error())
|
||||
}
|
||||
|
||||
return "", false
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ package log
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fatih/color"
|
||||
"os"
|
||||
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -81,7 +82,7 @@ func Error(msg string) {
|
|||
|
||||
// Errorf prints an error message with optional format verbs
|
||||
func Errorf(msg string, v ...interface{}) {
|
||||
fmt.Fprintf(color.Output, "%s%s %s", indent, ColorRed.Sprintf("⨯"), fmt.Sprintf(msg, v...))
|
||||
fmt.Fprintf(color.Output, "%s%s %s", indent, ColorRed.Sprintf("%s", "⨯"), fmt.Sprintf(msg, v...))
|
||||
}
|
||||
|
||||
// Printf prints an normal message
|
||||
|
|
@ -96,9 +97,9 @@ func Askf(msg string, masked bool, v ...interface{}) {
|
|||
|
||||
var symbol string
|
||||
if masked {
|
||||
symbol = ColorGray.Sprintf(symbolChar)
|
||||
symbol = ColorGray.Sprintf("%s", symbolChar)
|
||||
} else {
|
||||
symbol = ColorGreen.Sprintf(symbolChar)
|
||||
symbol = ColorGreen.Sprintf("%s", symbolChar)
|
||||
}
|
||||
|
||||
fmt.Fprintf(color.Output, "%s%s %s: ", indent, symbol, fmt.Sprintf(msg, v...))
|
||||
|
|
|
|||
|
|
@ -227,8 +227,8 @@ type systemState struct {
|
|||
clientBookCount int
|
||||
clientLastMaxUSN int
|
||||
clientLastSyncAt int64
|
||||
serverNoteCount int
|
||||
serverBookCount int
|
||||
serverNoteCount int64
|
||||
serverBookCount int64
|
||||
serverUserMaxUSN int
|
||||
}
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ func checkState(t *testing.T, ctx context.DnoteCtx, user database.User, expected
|
|||
assert.Equal(t, clientLastMaxUSN, expected.clientLastMaxUSN, "client last_max_usn mismatch")
|
||||
assert.Equal(t, clientLastSyncAt, expected.clientLastSyncAt, "client last_sync_at mismatch")
|
||||
|
||||
var serverBookCount, serverNoteCount int
|
||||
var serverBookCount, serverNoteCount int64
|
||||
apitest.MustExec(t, serverDB.Model(&database.Note{}).Count(&serverNoteCount), "counting server notes")
|
||||
apitest.MustExec(t, serverDB.Model(&database.Book{}).Count(&serverBookCount), "counting api notes")
|
||||
assert.Equal(t, serverNoteCount, expected.serverNoteCount, "server note count mismatch")
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"github.com/dnote/dnote/pkg/clock"
|
||||
"github.com/dnote/dnote/pkg/server/config"
|
||||
"github.com/dnote/dnote/pkg/server/mailer"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ package app
|
|||
import (
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/dnote/dnote/pkg/server/helpers"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ func (a *App) DeleteBook(tx *gorm.DB, user database.User, book database.Book) (d
|
|||
}
|
||||
|
||||
if err := tx.Model(&book).
|
||||
Update(map[string]interface{}{
|
||||
Updates(map[string]interface{}{
|
||||
"usn": nextUSN,
|
||||
"deleted": true,
|
||||
"label": "",
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ func TestCreateBook(t *testing.T) {
|
|||
t.Fatal(errors.Wrap(err, "creating book"))
|
||||
}
|
||||
|
||||
var bookCount int
|
||||
var bookCount int64
|
||||
var bookRecord database.Book
|
||||
var userRecord database.User
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ func TestCreateBook(t *testing.T) {
|
|||
t.Fatal(errors.Wrap(err, "finding user"))
|
||||
}
|
||||
|
||||
assert.Equal(t, bookCount, 1, "book count mismatch")
|
||||
assert.Equal(t, bookCount, int64(1), "book count mismatch")
|
||||
assert.Equal(t, bookRecord.UserID, user.ID, "book user_id mismatch")
|
||||
assert.Equal(t, bookRecord.Label, tc.label, "book label mismatch")
|
||||
assert.Equal(t, bookRecord.USN, tc.expectedUSN, "book label mismatch")
|
||||
|
|
@ -140,7 +140,7 @@ func TestDeleteBook(t *testing.T) {
|
|||
}
|
||||
tx.Commit()
|
||||
|
||||
var bookCount int
|
||||
var bookCount int64
|
||||
var bookRecord database.Book
|
||||
var userRecord database.User
|
||||
|
||||
|
|
@ -148,7 +148,7 @@ func TestDeleteBook(t *testing.T) {
|
|||
testutils.MustExec(t, testutils.DB.First(&bookRecord), fmt.Sprintf("finding book for test case %d", idx))
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), fmt.Sprintf("finding user for test case %d", idx))
|
||||
|
||||
assert.Equal(t, bookCount, 1, "book count mismatch")
|
||||
assert.Equal(t, bookCount, int64(1), "book count mismatch")
|
||||
assert.Equal(t, bookRecord.UserID, user.ID, "book user_id mismatch")
|
||||
assert.Equal(t, bookRecord.Label, "", "book label mismatch")
|
||||
assert.Equal(t, bookRecord.Deleted, true, "book deleted flag mismatch")
|
||||
|
|
@ -223,14 +223,14 @@ func TestUpdateBook(t *testing.T) {
|
|||
|
||||
tx.Commit()
|
||||
|
||||
var bookCount int
|
||||
var bookCount int64
|
||||
var bookRecord database.Book
|
||||
var userRecord database.User
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Book{}).Count(&bookCount), fmt.Sprintf("counting books for test case %d", idx))
|
||||
testutils.MustExec(t, testutils.DB.First(&bookRecord), fmt.Sprintf("finding book for test case %d", idx))
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), fmt.Sprintf("finding user for test case %d", idx))
|
||||
|
||||
assert.Equal(t, bookCount, 1, "book count mismatch")
|
||||
assert.Equal(t, bookCount, int64(1), "book count mismatch")
|
||||
|
||||
assert.Equal(t, bookRecord.UserID, user.ID, "book user_id mismatch")
|
||||
assert.Equal(t, bookRecord.Label, tc.expectedLabel, "book label mismatch")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package app
|
|||
|
||||
import (
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/dnote/dnote/pkg/server/helpers"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
pkgErrors "github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// CreateNote creates a note with the next usn and updates the user's max_usn.
|
||||
|
|
@ -36,7 +37,7 @@ func (a *App) CreateNote(user database.User, bookUUID, content string, addedOn *
|
|||
nextUSN, err := incrementUserUSN(tx, user.ID)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return database.Note{}, errors.Wrap(err, "incrementing user max_usn")
|
||||
return database.Note{}, pkgErrors.Wrap(err, "incrementing user max_usn")
|
||||
}
|
||||
|
||||
var noteAddedOn int64
|
||||
|
|
@ -72,7 +73,7 @@ func (a *App) CreateNote(user database.User, bookUUID, content string, addedOn *
|
|||
}
|
||||
if err := tx.Create(¬e).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return note, errors.Wrap(err, "inserting note")
|
||||
return note, pkgErrors.Wrap(err, "inserting note")
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -118,7 +119,7 @@ func (r UpdateNoteParams) GetPublic() bool {
|
|||
func (a *App) UpdateNote(tx *gorm.DB, user database.User, note database.Note, p *UpdateNoteParams) (database.Note, error) {
|
||||
nextUSN, err := incrementUserUSN(tx, user.ID)
|
||||
if err != nil {
|
||||
return note, errors.Wrap(err, "incrementing user max_usn")
|
||||
return note, pkgErrors.Wrap(err, "incrementing user max_usn")
|
||||
}
|
||||
|
||||
if p.BookUUID != nil {
|
||||
|
|
@ -138,7 +139,7 @@ func (a *App) UpdateNote(tx *gorm.DB, user database.User, note database.Note, p
|
|||
note.Encrypted = false
|
||||
|
||||
if err := tx.Save(¬e).Error; err != nil {
|
||||
return note, errors.Wrap(err, "editing note")
|
||||
return note, pkgErrors.Wrap(err, "editing note")
|
||||
}
|
||||
|
||||
return note, nil
|
||||
|
|
@ -148,16 +149,16 @@ func (a *App) UpdateNote(tx *gorm.DB, user database.User, note database.Note, p
|
|||
func (a *App) DeleteNote(tx *gorm.DB, user database.User, note database.Note) (database.Note, error) {
|
||||
nextUSN, err := incrementUserUSN(tx, user.ID)
|
||||
if err != nil {
|
||||
return note, errors.Wrap(err, "incrementing user max_usn")
|
||||
return note, pkgErrors.Wrap(err, "incrementing user max_usn")
|
||||
}
|
||||
|
||||
if err := tx.Model(¬e).
|
||||
Update(map[string]interface{}{
|
||||
Updates(map[string]interface{}{
|
||||
"usn": nextUSN,
|
||||
"deleted": true,
|
||||
"body": "",
|
||||
}).Error; err != nil {
|
||||
return note, errors.Wrap(err, "deleting note")
|
||||
return note, pkgErrors.Wrap(err, "deleting note")
|
||||
}
|
||||
|
||||
return note, nil
|
||||
|
|
@ -166,13 +167,13 @@ func (a *App) DeleteNote(tx *gorm.DB, user database.User, note database.Note) (d
|
|||
// GetUserNoteByUUID retrives a digest by the uuid for the given user
|
||||
func (a *App) GetUserNoteByUUID(userID int, uuid string) (*database.Note, error) {
|
||||
var ret database.Note
|
||||
conn := a.DB.Where("user_id = ? AND uuid = ?", userID, uuid).First(&ret)
|
||||
err := a.DB.Where("user_id = ? AND uuid = ?", userID, uuid).First(&ret).Error
|
||||
|
||||
if conn.RecordNotFound() {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, nil
|
||||
}
|
||||
if err := conn.Error; err != nil {
|
||||
return nil, errors.Wrap(err, "finding digest")
|
||||
if err != nil {
|
||||
return nil, pkgErrors.Wrap(err, "finding digest")
|
||||
}
|
||||
|
||||
return &ret, nil
|
||||
|
|
@ -288,16 +289,16 @@ func paginate(conn *gorm.DB, page, perPage int) *gorm.DB {
|
|||
// GetNotesResult is the result of getting notes
|
||||
type GetNotesResult struct {
|
||||
Notes []database.Note
|
||||
Total int
|
||||
Total int64
|
||||
}
|
||||
|
||||
// GetNotes returns a list of matching notes
|
||||
func (a *App) GetNotes(userID int, params GetNotesParams) (GetNotesResult, error) {
|
||||
conn := getNotesBaseQuery(a.DB, userID, params)
|
||||
|
||||
var total int
|
||||
var total int64
|
||||
if err := conn.Model(database.Note{}).Count(&total).Error; err != nil {
|
||||
return GetNotesResult{}, errors.Wrap(err, "counting total")
|
||||
return GetNotesResult{}, pkgErrors.Wrap(err, "counting total")
|
||||
}
|
||||
|
||||
notes := []database.Note{}
|
||||
|
|
@ -307,7 +308,7 @@ func (a *App) GetNotes(userID int, params GetNotesParams) (GetNotesResult, error
|
|||
conn = paginate(conn, params.Page, params.PerPage)
|
||||
|
||||
if err := conn.Find(¬es).Error; err != nil {
|
||||
return GetNotesResult{}, errors.Wrap(err, "finding notes")
|
||||
return GetNotesResult{}, pkgErrors.Wrap(err, "finding notes")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ func TestCreateNote(t *testing.T) {
|
|||
}
|
||||
tx.Commit()
|
||||
|
||||
var bookCount, noteCount int
|
||||
var bookCount, noteCount int64
|
||||
var noteRecord database.Note
|
||||
var userRecord database.User
|
||||
|
||||
|
|
@ -105,8 +105,8 @@ func TestCreateNote(t *testing.T) {
|
|||
testutils.MustExec(t, testutils.DB.First(¬eRecord), fmt.Sprintf("finding note for test case %d", idx))
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), fmt.Sprintf("finding user for test case %d", idx))
|
||||
|
||||
assert.Equal(t, bookCount, 1, "book count mismatch")
|
||||
assert.Equal(t, noteCount, 1, "note count mismatch")
|
||||
assert.Equal(t, bookCount, int64(1), "book count mismatch")
|
||||
assert.Equal(t, noteCount, int64(1), "note count mismatch")
|
||||
assert.NotEqual(t, noteRecord.UUID, "", "note UUID should have been generated")
|
||||
assert.Equal(t, noteRecord.UserID, user.ID, "note UserID mismatch")
|
||||
assert.Equal(t, noteRecord.Body, "note content", "note Body mismatch")
|
||||
|
|
@ -169,7 +169,7 @@ func TestUpdateNote(t *testing.T) {
|
|||
}
|
||||
tx.Commit()
|
||||
|
||||
var bookCount, noteCount int
|
||||
var bookCount, noteCount int64
|
||||
var noteRecord database.Note
|
||||
var userRecord database.User
|
||||
|
||||
|
|
@ -179,8 +179,8 @@ func TestUpdateNote(t *testing.T) {
|
|||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), "finding user for test case")
|
||||
|
||||
expectedUSN := tc.userUSN + 1
|
||||
assert.Equal(t, bookCount, 1, "book count mismatch")
|
||||
assert.Equal(t, noteCount, 1, "note count mismatch")
|
||||
assert.Equal(t, bookCount, int64(1), "book count mismatch")
|
||||
assert.Equal(t, noteCount, int64(1), "note count mismatch")
|
||||
assert.Equal(t, noteRecord.UserID, user.ID, "note UserID mismatch")
|
||||
assert.Equal(t, noteRecord.Body, content, "note Body mismatch")
|
||||
assert.Equal(t, noteRecord.Public, public, "note Public mismatch")
|
||||
|
|
@ -236,7 +236,7 @@ func TestDeleteNote(t *testing.T) {
|
|||
}
|
||||
tx.Commit()
|
||||
|
||||
var noteCount int
|
||||
var noteCount int64
|
||||
var noteRecord database.Note
|
||||
var userRecord database.User
|
||||
|
||||
|
|
@ -244,7 +244,7 @@ func TestDeleteNote(t *testing.T) {
|
|||
testutils.MustExec(t, testutils.DB.First(¬eRecord), fmt.Sprintf("finding note for test case %d", idx))
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), fmt.Sprintf("finding user for test case %d", idx))
|
||||
|
||||
assert.Equal(t, noteCount, 1, "note count mismatch")
|
||||
assert.Equal(t, noteCount, int64(1), "note count mismatch")
|
||||
|
||||
assert.Equal(t, noteRecord.UserID, user.ID, "note user_id mismatch")
|
||||
assert.Equal(t, noteRecord.Body, "", "note content mismatch")
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import (
|
|||
|
||||
"github.com/dnote/dnote/pkg/server/crypt"
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,19 +19,21 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/dnote/dnote/pkg/server/log"
|
||||
"github.com/dnote/dnote/pkg/server/token"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
pkgErrors "github.com/pkg/errors"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
// TouchLastLoginAt updates the last login timestamp
|
||||
func (a *App) TouchLastLoginAt(user database.User, tx *gorm.DB) error {
|
||||
t := a.Clock.Now()
|
||||
if err := tx.Model(&user).Update(database.User{LastLoginAt: &t}).Error; err != nil {
|
||||
return errors.Wrap(err, "updating last_login_at")
|
||||
if err := tx.Model(&user).Update("last_login_at", &t).Error; err != nil {
|
||||
return pkgErrors.Wrap(err, "updating last_login_at")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -42,7 +44,7 @@ func createEmailPreference(user database.User, tx *gorm.DB) error {
|
|||
UserID: user.ID,
|
||||
}
|
||||
if err := tx.Save(&p).Error; err != nil {
|
||||
return errors.Wrap(err, "inserting email preference")
|
||||
return pkgErrors.Wrap(err, "inserting email preference")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -64,9 +66,9 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d
|
|||
|
||||
tx := a.DB.Begin()
|
||||
|
||||
var count int
|
||||
var count int64
|
||||
if err := tx.Model(database.Account{}).Where("email = ?", email).Count(&count).Error; err != nil {
|
||||
return database.User{}, errors.Wrap(err, "counting user")
|
||||
return database.User{}, pkgErrors.Wrap(err, "counting user")
|
||||
}
|
||||
if count > 0 {
|
||||
return database.User{}, ErrDuplicateEmail
|
||||
|
|
@ -75,7 +77,7 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d
|
|||
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return database.User{}, errors.Wrap(err, "hashing password")
|
||||
return database.User{}, pkgErrors.Wrap(err, "hashing password")
|
||||
}
|
||||
|
||||
// Grant all privileges if self-hosting
|
||||
|
|
@ -91,7 +93,7 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d
|
|||
}
|
||||
if err = tx.Save(&user).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return database.User{}, errors.Wrap(err, "saving user")
|
||||
return database.User{}, pkgErrors.Wrap(err, "saving user")
|
||||
}
|
||||
account := database.Account{
|
||||
Email: database.ToNullString(email),
|
||||
|
|
@ -100,20 +102,20 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d
|
|||
}
|
||||
if err = tx.Save(&account).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return database.User{}, errors.Wrap(err, "saving account")
|
||||
return database.User{}, pkgErrors.Wrap(err, "saving account")
|
||||
}
|
||||
|
||||
if _, err := token.Create(tx, user.ID, database.TokenTypeEmailPreference); err != nil {
|
||||
tx.Rollback()
|
||||
return database.User{}, errors.Wrap(err, "creating email verificaiton token")
|
||||
return database.User{}, pkgErrors.Wrap(err, "creating email verificaiton token")
|
||||
}
|
||||
if err := createEmailPreference(user, tx); err != nil {
|
||||
tx.Rollback()
|
||||
return database.User{}, errors.Wrap(err, "creating email preference")
|
||||
return database.User{}, pkgErrors.Wrap(err, "creating email preference")
|
||||
}
|
||||
if err := a.TouchLastLoginAt(user, tx); err != nil {
|
||||
tx.Rollback()
|
||||
return database.User{}, errors.Wrap(err, "updating last login")
|
||||
return database.User{}, pkgErrors.Wrap(err, "updating last login")
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -124,14 +126,14 @@ func (a *App) CreateUser(email, password string, passwordConfirmation string) (d
|
|||
// Authenticate authenticates a user
|
||||
func (a *App) Authenticate(email, password string) (*database.User, error) {
|
||||
var account database.Account
|
||||
conn := a.DB.Where("email = ?", email).First(&account)
|
||||
if conn.RecordNotFound() {
|
||||
err := a.DB.Where("email = ?", email).First(&account).Error
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return nil, ErrNotFound
|
||||
} else if conn.Error != nil {
|
||||
return nil, conn.Error
|
||||
} else if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := bcrypt.CompareHashAndPassword([]byte(account.Password.String), []byte(password))
|
||||
err = bcrypt.CompareHashAndPassword([]byte(account.Password.String), []byte(password))
|
||||
if err != nil {
|
||||
return nil, ErrLoginInvalid
|
||||
}
|
||||
|
|
@ -139,7 +141,7 @@ func (a *App) Authenticate(email, password string) (*database.User, error) {
|
|||
var user database.User
|
||||
err = a.DB.Where("id = ?", account.UserID).First(&user).Error
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "finding user")
|
||||
return nil, pkgErrors.Wrap(err, "finding user")
|
||||
}
|
||||
|
||||
return &user, nil
|
||||
|
|
@ -154,7 +156,7 @@ func (a *App) SignIn(user *database.User) (*database.Session, error) {
|
|||
|
||||
session, err := a.CreateSession(user.ID)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "creating session")
|
||||
return nil, pkgErrors.Wrap(err, "creating session")
|
||||
}
|
||||
|
||||
return &session, nil
|
||||
|
|
|
|||
|
|
@ -59,12 +59,12 @@ func TestCreateUser_ProValue(t *testing.T) {
|
|||
t.Fatal(errors.Wrap(err, "executing"))
|
||||
}
|
||||
|
||||
var userCount int
|
||||
var userCount int64
|
||||
var userRecord database.User
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.User{}).Count(&userCount), "counting user")
|
||||
testutils.MustExec(t, testutils.DB.First(&userRecord), "finding user")
|
||||
|
||||
assert.Equal(t, userCount, 1, "book count mismatch")
|
||||
assert.Equal(t, userCount, int64(1), "book count mismatch")
|
||||
assert.Equal(t, userRecord.Cloud, tc.expectedPro, "user pro mismatch")
|
||||
})
|
||||
}
|
||||
|
|
@ -82,16 +82,16 @@ func TestCreateUser(t *testing.T) {
|
|||
t.Fatal(errors.Wrap(err, "executing"))
|
||||
}
|
||||
|
||||
var userCount int
|
||||
var userCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.User{}).Count(&userCount), "counting user")
|
||||
assert.Equal(t, userCount, 1, "book count mismatch")
|
||||
assert.Equal(t, userCount, int64(1), "book count mismatch")
|
||||
|
||||
var accountCount int
|
||||
var accountCount int64
|
||||
var accountRecord database.Account
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Account{}).Count(&accountCount), "counting account")
|
||||
testutils.MustExec(t, testutils.DB.First(&accountRecord), "finding account")
|
||||
|
||||
assert.Equal(t, accountCount, 1, "account count mismatch")
|
||||
assert.Equal(t, accountCount, int64(1), "account count mismatch")
|
||||
assert.Equal(t, accountRecord.Email.String, "alice@example.com", "account email mismatch")
|
||||
|
||||
passwordErr := bcrypt.CompareHashAndPassword([]byte(accountRecord.Password.String), []byte("pass1234"))
|
||||
|
|
@ -101,21 +101,19 @@ func TestCreateUser(t *testing.T) {
|
|||
t.Run("duplicate email", func(t *testing.T) {
|
||||
defer testutils.ClearData(testutils.DB)
|
||||
|
||||
aliceUser := database.User{}
|
||||
aliceAccount := database.Account{UserID: aliceUser.ID, Email: database.ToNullString("alice@example.com")}
|
||||
testutils.MustExec(t, testutils.DB.Save(&aliceUser), "preparing a user")
|
||||
testutils.MustExec(t, testutils.DB.Save(&aliceAccount), "preparing an account")
|
||||
aliceUser := testutils.SetupUserData()
|
||||
testutils.SetupAccountData(aliceUser, "alice@example.com", "somepassword")
|
||||
|
||||
a := NewTest(nil)
|
||||
_, err := a.CreateUser("alice@example.com", "newpassword", "newpassword")
|
||||
|
||||
assert.Equal(t, err, ErrDuplicateEmail, "error mismatch")
|
||||
|
||||
var userCount, accountCount int
|
||||
var userCount, accountCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.User{}).Count(&userCount), "counting user")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Account{}).Count(&accountCount), "counting account")
|
||||
|
||||
assert.Equal(t, userCount, 1, "user count mismatch")
|
||||
assert.Equal(t, accountCount, 1, "account count mismatch")
|
||||
assert.Equal(t, userCount, int64(1), "user count mismatch")
|
||||
assert.Equal(t, accountCount, int64(1), "account count mismatch")
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
|
@ -28,7 +29,8 @@ import (
|
|||
"github.com/dnote/dnote/pkg/server/helpers"
|
||||
"github.com/dnote/dnote/pkg/server/presenters"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
pkgErrors "github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// NewBooks creates a new Books controller.
|
||||
|
|
@ -107,13 +109,13 @@ func (b *Books) V3Show(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
var book database.Book
|
||||
conn := b.app.DB.Where("uuid = ? AND user_id = ?", bookUUID, user.ID).First(&book)
|
||||
err := b.app.DB.Where("uuid = ? AND user_id = ?", bookUUID, user.ID).First(&book).Error
|
||||
|
||||
if conn.RecordNotFound() {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
if err := conn.Error; err != nil {
|
||||
if err != nil {
|
||||
handleJSONError(w, err, "finding the book")
|
||||
return
|
||||
}
|
||||
|
|
@ -141,19 +143,19 @@ func (b *Books) create(r *http.Request) (database.Book, error) {
|
|||
|
||||
var params createBookPayload
|
||||
if err := parseRequestData(r, ¶ms); err != nil {
|
||||
return database.Book{}, errors.Wrap(err, "parsing request payload")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "parsing request payload")
|
||||
}
|
||||
|
||||
if err := validateCreateBookPayload(params); err != nil {
|
||||
return database.Book{}, errors.Wrap(err, "validating payload")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "validating payload")
|
||||
}
|
||||
|
||||
var bookCount int
|
||||
var bookCount int64
|
||||
err := b.app.DB.Model(database.Book{}).
|
||||
Where("user_id = ? AND label = ?", user.ID, params.Name).
|
||||
Count(&bookCount).Error
|
||||
if err != nil {
|
||||
return database.Book{}, errors.Wrap(err, "checking duplicate")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "checking duplicate")
|
||||
}
|
||||
if bookCount > 0 {
|
||||
return database.Book{}, app.ErrDuplicateBook
|
||||
|
|
@ -161,7 +163,7 @@ func (b *Books) create(r *http.Request) (database.Book, error) {
|
|||
|
||||
book, err := b.app.CreateBook(*user, params.Name)
|
||||
if err != nil {
|
||||
return database.Book{}, errors.Wrap(err, "inserting a book")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "inserting a book")
|
||||
}
|
||||
|
||||
return book, nil
|
||||
|
|
@ -212,18 +214,18 @@ func (b *Books) update(r *http.Request) (database.Book, error) {
|
|||
|
||||
var book database.Book
|
||||
if err := tx.Where("user_id = ? AND uuid = ?", user.ID, uuid).First(&book).Error; err != nil {
|
||||
return database.Book{}, errors.Wrap(err, "finding book")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "finding book")
|
||||
}
|
||||
|
||||
var params updateBookPayload
|
||||
if err := parseRequestData(r, ¶ms); err != nil {
|
||||
return database.Book{}, errors.Wrap(err, "decoding payload")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "decoding payload")
|
||||
}
|
||||
|
||||
book, err := b.app.UpdateBook(tx, *user, book, params.Name)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return database.Book{}, errors.Wrap(err, "updating a book")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "updating a book")
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
@ -262,24 +264,24 @@ func (b *Books) del(r *http.Request) (database.Book, error) {
|
|||
|
||||
var book database.Book
|
||||
if err := tx.Where("user_id = ? AND uuid = ?", user.ID, uuid).First(&book).Error; err != nil {
|
||||
return database.Book{}, errors.Wrap(err, "finding a book")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "finding a book")
|
||||
}
|
||||
|
||||
var notes []database.Note
|
||||
if err := tx.Where("book_uuid = ? AND NOT deleted", uuid).Order("usn ASC").Find(¬es).Error; err != nil {
|
||||
return database.Book{}, errors.Wrap(err, "finding notes for the book")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "finding notes for the book")
|
||||
}
|
||||
|
||||
for _, note := range notes {
|
||||
if _, err := b.app.DeleteNote(tx, *user, note); err != nil {
|
||||
tx.Rollback()
|
||||
return database.Book{}, errors.Wrap(err, "deleting a note in the book")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "deleting a note in the book")
|
||||
}
|
||||
}
|
||||
|
||||
book, err := b.app.DeleteBook(tx, *user, book)
|
||||
if err != nil {
|
||||
return database.Book{}, errors.Wrap(err, "deleting the book")
|
||||
return database.Book{}, pkgErrors.Wrap(err, "deleting the book")
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
|
|
|||
|
|
@ -298,7 +298,7 @@ func TestCreateBook(t *testing.T) {
|
|||
|
||||
var bookRecord database.Book
|
||||
var userRecord database.User
|
||||
var bookCount, noteCount int
|
||||
var bookCount, noteCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Book{}).Count(&bookCount), "counting books")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Note{}).Count(¬eCount), "counting notes")
|
||||
testutils.MustExec(t, testutils.DB.First(&bookRecord), "finding book")
|
||||
|
|
@ -306,8 +306,8 @@ func TestCreateBook(t *testing.T) {
|
|||
|
||||
maxUSN := 102
|
||||
|
||||
assert.Equalf(t, bookCount, 1, "book count mismatch")
|
||||
assert.Equalf(t, noteCount, 0, "note count mismatch")
|
||||
assert.Equalf(t, bookCount, int64(1), "book count mismatch")
|
||||
assert.Equalf(t, noteCount, int64(0), "note count mismatch")
|
||||
|
||||
assert.NotEqual(t, bookRecord.UUID, "", "book uuid should have been generated")
|
||||
assert.Equal(t, bookRecord.Label, "js", "book name mismatch")
|
||||
|
|
@ -361,15 +361,15 @@ func TestCreateBook(t *testing.T) {
|
|||
assert.StatusCodeEquals(t, res, http.StatusConflict, "")
|
||||
|
||||
var bookRecord database.Book
|
||||
var bookCount, noteCount int
|
||||
var bookCount, noteCount int64
|
||||
var userRecord database.User
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Book{}).Count(&bookCount), "counting books")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Note{}).Count(¬eCount), "counting notes")
|
||||
testutils.MustExec(t, testutils.DB.First(&bookRecord), "finding book")
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), "finding user record")
|
||||
|
||||
assert.Equalf(t, bookCount, 1, "book count mismatch")
|
||||
assert.Equalf(t, noteCount, 0, "note count mismatch")
|
||||
assert.Equalf(t, bookCount, int64(1), "book count mismatch")
|
||||
assert.Equalf(t, noteCount, int64(0), "note count mismatch")
|
||||
|
||||
assert.Equal(t, bookRecord.Label, "js", "book name mismatch")
|
||||
assert.Equal(t, bookRecord.UserID, user.ID, "book user_id mismatch")
|
||||
|
|
@ -459,14 +459,14 @@ func TestUpdateBook(t *testing.T) {
|
|||
|
||||
var bookRecord database.Book
|
||||
var userRecord database.User
|
||||
var noteCount, bookCount int
|
||||
var noteCount, bookCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Book{}).Count(&bookCount), "counting books")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Note{}).Count(¬eCount), "counting notes")
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", b1.ID).First(&bookRecord), "finding book")
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), "finding user record")
|
||||
|
||||
assert.Equalf(t, bookCount, 2, "book count mismatch")
|
||||
assert.Equalf(t, noteCount, 0, "note count mismatch")
|
||||
assert.Equalf(t, bookCount, int64(2), "book count mismatch")
|
||||
assert.Equalf(t, noteCount, int64(0), "note count mismatch")
|
||||
|
||||
assert.Equalf(t, bookRecord.UUID, tc.bookUUID, "book uuid mismatch")
|
||||
assert.Equalf(t, bookRecord.Label, tc.expectedBookLabel, "book label mismatch")
|
||||
|
|
@ -603,7 +603,7 @@ func TestDeleteBook(t *testing.T) {
|
|||
var b1Record, b2Record, b3Record database.Book
|
||||
var n1Record, n2Record, n3Record, n4Record, n5Record database.Note
|
||||
var userRecord database.User
|
||||
var bookCount, noteCount int
|
||||
var bookCount, noteCount int64
|
||||
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Book{}).Count(&bookCount), "counting books")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Note{}).Count(¬eCount), "counting notes")
|
||||
|
|
@ -617,8 +617,8 @@ func TestDeleteBook(t *testing.T) {
|
|||
testutils.MustExec(t, testutils.DB.Where("id = ?", n5.ID).First(&n5Record), "finding n5")
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), "finding user record")
|
||||
|
||||
assert.Equal(t, bookCount, 3, "book count mismatch")
|
||||
assert.Equal(t, noteCount, 5, "note count mismatch")
|
||||
assert.Equal(t, bookCount, int64(3), "book count mismatch")
|
||||
assert.Equal(t, noteCount, int64(5), "note count mismatch")
|
||||
|
||||
assert.Equal(t, userRecord.MaxUSN, tc.expectedMaxUSN, "user max_usn mismatch")
|
||||
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ func getMaxPage(page, total int) int {
|
|||
// GetNotesResponse is a reponse by getNotesHandler
|
||||
type GetNotesResponse struct {
|
||||
Notes []presenters.Note `json:"notes"`
|
||||
Total int `json:"total"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
// V3Index is a v3 handler for getting notes
|
||||
|
|
|
|||
|
|
@ -400,15 +400,15 @@ func TestCreateNote(t *testing.T) {
|
|||
var noteRecord database.Note
|
||||
var bookRecord database.Book
|
||||
var userRecord database.User
|
||||
var bookCount, noteCount int
|
||||
var bookCount, noteCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Book{}).Count(&bookCount), "counting books")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Note{}).Count(¬eCount), "counting notes")
|
||||
testutils.MustExec(t, testutils.DB.First(¬eRecord), "finding note")
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", b1.ID).First(&bookRecord), "finding book")
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), "finding user record")
|
||||
|
||||
assert.Equalf(t, bookCount, 1, "book count mismatch")
|
||||
assert.Equalf(t, noteCount, 1, "note count mismatch")
|
||||
assert.Equalf(t, bookCount, int64(1), "book count mismatch")
|
||||
assert.Equalf(t, noteCount, int64(1), "note count mismatch")
|
||||
|
||||
assert.Equal(t, bookRecord.Label, b1.Label, "book name mismatch")
|
||||
assert.Equal(t, bookRecord.UUID, b1.UUID, "book uuid mismatch")
|
||||
|
|
@ -488,15 +488,15 @@ func TestDeleteNote(t *testing.T) {
|
|||
var bookRecord database.Book
|
||||
var noteRecord database.Note
|
||||
var userRecord database.User
|
||||
var bookCount, noteCount int
|
||||
var bookCount, noteCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Book{}).Count(&bookCount), "counting books")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Note{}).Count(¬eCount), "counting notes")
|
||||
testutils.MustExec(t, testutils.DB.Where("uuid = ?", note.UUID).First(¬eRecord), "finding note")
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", b1.ID).First(&bookRecord), "finding book")
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), "finding user record")
|
||||
|
||||
assert.Equalf(t, bookCount, 1, "book count mismatch")
|
||||
assert.Equalf(t, noteCount, 1, "note count mismatch")
|
||||
assert.Equalf(t, bookCount, int64(1), "book count mismatch")
|
||||
assert.Equalf(t, noteCount, int64(1), "note count mismatch")
|
||||
|
||||
assert.Equal(t, noteRecord.UUID, note.UUID, "note uuid mismatch for test case")
|
||||
assert.Equal(t, noteRecord.Body, "", "note content mismatch for test case")
|
||||
|
|
@ -738,15 +738,15 @@ func TestUpdateNote(t *testing.T) {
|
|||
var bookRecord database.Book
|
||||
var noteRecord database.Note
|
||||
var userRecord database.User
|
||||
var noteCount, bookCount int
|
||||
var noteCount, bookCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Book{}).Count(&bookCount), "counting books")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Note{}).Count(¬eCount), "counting notes")
|
||||
testutils.MustExec(t, testutils.DB.Where("uuid = ?", note.UUID).First(¬eRecord), "finding note")
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", b1.ID).First(&bookRecord), "finding book")
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", user.ID).First(&userRecord), "finding user record")
|
||||
|
||||
assert.Equalf(t, bookCount, 2, "book count mismatch")
|
||||
assert.Equalf(t, noteCount, 1, "note count mismatch")
|
||||
assert.Equalf(t, bookCount, int64(2), "book count mismatch")
|
||||
assert.Equalf(t, noteCount, int64(1), "note count mismatch")
|
||||
|
||||
assert.Equal(t, noteRecord.UUID, tc.noteUUID, "note uuid mismatch for test case")
|
||||
assert.Equal(t, noteRecord.Body, tc.expectedNoteBody, "note content mismatch for test case")
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
|
@ -33,7 +34,8 @@ import (
|
|||
"github.com/dnote/dnote/pkg/server/token"
|
||||
"github.com/dnote/dnote/pkg/server/views"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
pkgErrors "github.com/pkg/errors"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
|
|
@ -247,7 +249,7 @@ func (u *Users) V3Login(w http.ResponseWriter, r *http.Request) {
|
|||
func (u *Users) logout(r *http.Request) (bool, error) {
|
||||
key, err := GetCredential(r)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "getting credentials")
|
||||
return false, pkgErrors.Wrap(err, "getting credentials")
|
||||
}
|
||||
|
||||
if key == "" {
|
||||
|
|
@ -255,7 +257,7 @@ func (u *Users) logout(r *http.Request) (bool, error) {
|
|||
}
|
||||
|
||||
if err = u.app.DeleteSession(key); err != nil {
|
||||
return false, errors.Wrap(err, "deleting session")
|
||||
return false, pkgErrors.Wrap(err, "deleting session")
|
||||
}
|
||||
|
||||
return true, nil
|
||||
|
|
@ -312,11 +314,11 @@ func (u *Users) CreateResetToken(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
var account database.Account
|
||||
conn := u.app.DB.Where("email = ?", form.Email).First(&account)
|
||||
if conn.RecordNotFound() {
|
||||
err := u.app.DB.Where("email = ?", form.Email).First(&account).Error
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return
|
||||
}
|
||||
if err := conn.Error; err != nil {
|
||||
if err != nil {
|
||||
handleHTMLError(w, r, err, "finding account", u.PasswordResetView, vd)
|
||||
return
|
||||
}
|
||||
|
|
@ -379,12 +381,12 @@ func (u *Users) PasswordReset(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
var token database.Token
|
||||
conn := u.app.DB.Where("value = ? AND type =? AND used_at IS NULL", params.Token, database.TokenTypeResetPassword).First(&token)
|
||||
if conn.RecordNotFound() {
|
||||
err := u.app.DB.Where("value = ? AND type =? AND used_at IS NULL", params.Token, database.TokenTypeResetPassword).First(&token).Error
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
handleHTMLError(w, r, app.ErrInvalidToken, "invalid token", u.PasswordResetConfirmView, vd)
|
||||
return
|
||||
}
|
||||
if err := conn.Error; err != nil {
|
||||
if err != nil {
|
||||
handleHTMLError(w, r, err, "finding token", u.PasswordResetConfirmView, vd)
|
||||
return
|
||||
}
|
||||
|
|
@ -719,7 +721,7 @@ func (u *Users) CreateEmailVerificationToken(w http.ResponseWriter, r *http.Requ
|
|||
}
|
||||
|
||||
if err := u.app.SendVerificationEmail(account.Email.String, tok.Value); err != nil {
|
||||
if errors.Cause(err) == mailer.ErrSMTPNotConfigured {
|
||||
if pkgErrors.Cause(err) == mailer.ErrSMTPNotConfigured {
|
||||
handleHTMLError(w, r, app.ErrInvalidSMTPConfig, "SMTP config is not configured correctly.", u.SettingView, vd)
|
||||
} else {
|
||||
handleHTMLError(w, r, err, "sending verification email", u.SettingView, vd)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import (
|
|||
)
|
||||
|
||||
func assertResponseSessionCookie(t *testing.T, res *http.Response) {
|
||||
var sessionCount int
|
||||
var sessionCount int64
|
||||
var session database.Session
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Count(&sessionCount), "counting session")
|
||||
testutils.MustExec(t, testutils.DB.First(&session), "getting session")
|
||||
|
|
@ -159,12 +159,12 @@ func TestJoinError(t *testing.T) {
|
|||
// Test
|
||||
assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status mismatch")
|
||||
|
||||
var accountCount, userCount int
|
||||
var accountCount, userCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Account{}).Count(&accountCount), "counting account")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.User{}).Count(&userCount), "counting user")
|
||||
|
||||
assert.Equal(t, accountCount, 0, "accountCount mismatch")
|
||||
assert.Equal(t, userCount, 0, "userCount mismatch")
|
||||
assert.Equal(t, accountCount, int64(0), "accountCount mismatch")
|
||||
assert.Equal(t, userCount, int64(0), "userCount mismatch")
|
||||
})
|
||||
|
||||
t.Run("missing password", func(t *testing.T) {
|
||||
|
|
@ -187,12 +187,12 @@ func TestJoinError(t *testing.T) {
|
|||
// Test
|
||||
assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status mismatch")
|
||||
|
||||
var accountCount, userCount int
|
||||
var accountCount, userCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Account{}).Count(&accountCount), "counting account")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.User{}).Count(&userCount), "counting user")
|
||||
|
||||
assert.Equal(t, accountCount, 0, "accountCount mismatch")
|
||||
assert.Equal(t, userCount, 0, "userCount mismatch")
|
||||
assert.Equal(t, accountCount, int64(0), "accountCount mismatch")
|
||||
assert.Equal(t, userCount, int64(0), "userCount mismatch")
|
||||
})
|
||||
|
||||
t.Run("password confirmation mismatch", func(t *testing.T) {
|
||||
|
|
@ -217,12 +217,12 @@ func TestJoinError(t *testing.T) {
|
|||
// Test
|
||||
assert.StatusCodeEquals(t, res, http.StatusBadRequest, "Status mismatch")
|
||||
|
||||
var accountCount, userCount int
|
||||
var accountCount, userCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Account{}).Count(&accountCount), "counting account")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.User{}).Count(&userCount), "counting user")
|
||||
|
||||
assert.Equal(t, accountCount, 0, "accountCount mismatch")
|
||||
assert.Equal(t, userCount, 0, "userCount mismatch")
|
||||
assert.Equal(t, accountCount, int64(0), "accountCount mismatch")
|
||||
assert.Equal(t, userCount, int64(0), "userCount mismatch")
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -251,7 +251,7 @@ func TestJoinDuplicateEmail(t *testing.T) {
|
|||
// Test
|
||||
assert.StatusCodeEquals(t, res, http.StatusBadRequest, "status code mismatch")
|
||||
|
||||
var accountCount, userCount, verificationTokenCount int
|
||||
var accountCount, userCount, verificationTokenCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Account{}).Count(&accountCount), "counting account")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.User{}).Count(&userCount), "counting user")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Token{}).Count(&verificationTokenCount), "counting verification token")
|
||||
|
|
@ -259,9 +259,9 @@ func TestJoinDuplicateEmail(t *testing.T) {
|
|||
var user database.User
|
||||
testutils.MustExec(t, testutils.DB.Where("id = ?", u.ID).First(&user), "finding user")
|
||||
|
||||
assert.Equal(t, accountCount, 1, "account count mismatch")
|
||||
assert.Equal(t, userCount, 1, "user count mismatch")
|
||||
assert.Equal(t, verificationTokenCount, 0, "verification_token should not have been created")
|
||||
assert.Equal(t, accountCount, int64(1), "account count mismatch")
|
||||
assert.Equal(t, userCount, int64(1), "user count mismatch")
|
||||
assert.Equal(t, verificationTokenCount, int64(0), "verification_token should not have been created")
|
||||
assert.Equal(t, user.LastLoginAt, (*time.Time)(nil), "LastLoginAt mismatch")
|
||||
}
|
||||
|
||||
|
|
@ -288,12 +288,12 @@ func TestJoinDisabled(t *testing.T) {
|
|||
// Test
|
||||
assert.StatusCodeEquals(t, res, http.StatusNotFound, "status code mismatch")
|
||||
|
||||
var accountCount, userCount int
|
||||
var accountCount, userCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Account{}).Count(&accountCount), "counting account")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.User{}).Count(&userCount), "counting user")
|
||||
|
||||
assert.Equal(t, accountCount, 0, "account count mismatch")
|
||||
assert.Equal(t, userCount, 0, "user count mismatch")
|
||||
assert.Equal(t, accountCount, int64(0), "account count mismatch")
|
||||
assert.Equal(t, userCount, int64(0), "user count mismatch")
|
||||
}
|
||||
|
||||
func TestLogin(t *testing.T) {
|
||||
|
|
@ -344,12 +344,12 @@ func TestLogin(t *testing.T) {
|
|||
t.Fatal(errors.Wrap(err, "decoding payload"))
|
||||
}
|
||||
|
||||
var sessionCount int
|
||||
var sessionCount int64
|
||||
var session database.Session
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Count(&sessionCount), "counting session")
|
||||
testutils.MustExec(t, testutils.DB.First(&session), "getting session")
|
||||
|
||||
assert.Equal(t, sessionCount, 1, "sessionCount mismatch")
|
||||
assert.Equal(t, sessionCount, int64(1), "sessionCount mismatch")
|
||||
assert.Equal(t, got.Key, session.Key, "session Key mismatch")
|
||||
assert.Equal(t, got.ExpiresAt, session.ExpiresAt.Unix(), "session ExpiresAt mismatch")
|
||||
|
||||
|
|
@ -391,9 +391,9 @@ func TestLogin(t *testing.T) {
|
|||
testutils.MustExec(t, testutils.DB.Model(&database.User{}).First(&user), "finding user")
|
||||
assert.Equal(t, user.LastLoginAt, (*time.Time)(nil), "LastLoginAt mismatch")
|
||||
|
||||
var sessionCount int
|
||||
var sessionCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Count(&sessionCount), "counting session")
|
||||
assert.Equal(t, sessionCount, 0, "sessionCount mismatch")
|
||||
assert.Equal(t, sessionCount, int64(0), "sessionCount mismatch")
|
||||
})
|
||||
|
||||
testutils.RunForWebAndAPI(t, "wrong email", func(t *testing.T, target testutils.EndpointType) {
|
||||
|
|
@ -430,9 +430,9 @@ func TestLogin(t *testing.T) {
|
|||
testutils.MustExec(t, testutils.DB.Model(&database.User{}).First(&user), "finding user")
|
||||
assert.DeepEqual(t, user.LastLoginAt, (*time.Time)(nil), "LastLoginAt mismatch")
|
||||
|
||||
var sessionCount int
|
||||
var sessionCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Count(&sessionCount), "counting session")
|
||||
assert.Equal(t, sessionCount, 0, "sessionCount mismatch")
|
||||
assert.Equal(t, sessionCount, int64(0), "sessionCount mismatch")
|
||||
})
|
||||
|
||||
testutils.RunForWebAndAPI(t, "nonexistent email", func(t *testing.T, target testutils.EndpointType) {
|
||||
|
|
@ -462,9 +462,9 @@ func TestLogin(t *testing.T) {
|
|||
// Test
|
||||
assert.StatusCodeEquals(t, res, http.StatusUnauthorized, "")
|
||||
|
||||
var sessionCount int
|
||||
var sessionCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Count(&sessionCount), "counting session")
|
||||
assert.Equal(t, sessionCount, 0, "sessionCount mismatch")
|
||||
assert.Equal(t, sessionCount, int64(0), "sessionCount mismatch")
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -523,12 +523,12 @@ func TestLogout(t *testing.T) {
|
|||
assert.StatusCodeEquals(t, res, http.StatusNoContent, "Status mismatch")
|
||||
}
|
||||
|
||||
var sessionCount int
|
||||
var sessionCount int64
|
||||
var s2 database.Session
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Count(&sessionCount), "counting session")
|
||||
testutils.MustExec(t, testutils.DB.Where("key = ?", "MDCpbvCRg7W2sH6S870wqLqZDZTObYeVd0PzOekfo/A=").First(&s2), "getting s2")
|
||||
|
||||
assert.Equal(t, sessionCount, 1, "sessionCount mismatch")
|
||||
assert.Equal(t, sessionCount, int64(1), "sessionCount mismatch")
|
||||
|
||||
if target == testutils.EndpointWeb {
|
||||
c := testutils.GetCookieByName(res.Cookies(), "id")
|
||||
|
|
@ -565,14 +565,14 @@ func TestLogout(t *testing.T) {
|
|||
assert.StatusCodeEquals(t, res, http.StatusNoContent, "Status mismatch")
|
||||
}
|
||||
|
||||
var sessionCount int
|
||||
var sessionCount int64
|
||||
var postSession1, postSession2 database.Session
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Count(&sessionCount), "counting session")
|
||||
testutils.MustExec(t, testutils.DB.Where("key = ?", "A9xgggqzTHETy++GDi1NpDNe0iyqosPm9bitdeNGkJU=").First(&postSession1), "getting postSession1")
|
||||
testutils.MustExec(t, testutils.DB.Where("key = ?", "MDCpbvCRg7W2sH6S870wqLqZDZTObYeVd0PzOekfo/A=").First(&postSession2), "getting postSession2")
|
||||
|
||||
// two existing sessions should remain
|
||||
assert.Equal(t, sessionCount, 2, "sessionCount mismatch")
|
||||
assert.Equal(t, sessionCount, int64(2), "sessionCount mismatch")
|
||||
|
||||
c := testutils.GetCookieByName(res.Cookies(), "id")
|
||||
assert.Equal(t, c, (*http.Cookie)(nil), "id cookie should have not been set")
|
||||
|
|
@ -649,19 +649,19 @@ func TestResetPassword(t *testing.T) {
|
|||
assert.Equal(t, passwordErr, nil, "Password mismatch")
|
||||
assert.Equal(t, verificationToken.UsedAt, (*time.Time)(nil), "verificationToken UsedAt mismatch")
|
||||
|
||||
var s1Count, s2Count int
|
||||
var s1Count, s2Count int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Where("id = ?", s1.ID).Count(&s1Count), "counting s1")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Where("id = ?", s2.ID).Count(&s2Count), "counting s2")
|
||||
|
||||
assert.Equal(t, s1Count, 0, "s1 should have been deleted")
|
||||
assert.Equal(t, s2Count, 0, "s2 should have been deleted")
|
||||
assert.Equal(t, s1Count, int64(0), "s1 should have been deleted")
|
||||
assert.Equal(t, s2Count, int64(0), "s2 should have been deleted")
|
||||
|
||||
var userSessionCount, anotherUserSessionCount int
|
||||
var userSessionCount, anotherUserSessionCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Where("user_id = ?", u.ID).Count(&userSessionCount), "counting user session")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Session{}).Where("user_id = ?", anotherUser.ID).Count(&anotherUserSessionCount), "counting anotherUser session")
|
||||
|
||||
assert.Equal(t, userSessionCount, 0, "should have deleted a user session")
|
||||
assert.Equal(t, anotherUserSessionCount, 1, "anotherUser session count mismatch")
|
||||
assert.Equal(t, userSessionCount, int64(0), "should have deleted a user session")
|
||||
assert.Equal(t, anotherUserSessionCount, int64(1), "anotherUser session count mismatch")
|
||||
})
|
||||
|
||||
t.Run("nonexistent token", func(t *testing.T) {
|
||||
|
|
@ -786,12 +786,13 @@ func TestResetPassword(t *testing.T) {
|
|||
testutils.MustExec(t, testutils.DB.Where("id = ?", a.ID).First(&account), "failed to find account")
|
||||
assert.Equal(t, a.Password, account.Password, "password should not have been updated")
|
||||
|
||||
if resetToken.UsedAt.Year() != usedAt.Year() ||
|
||||
resetToken.UsedAt.Month() != usedAt.Month() ||
|
||||
resetToken.UsedAt.Day() != usedAt.Day() ||
|
||||
resetToken.UsedAt.Hour() != usedAt.Hour() ||
|
||||
resetToken.UsedAt.Minute() != usedAt.Minute() ||
|
||||
resetToken.UsedAt.Second() != usedAt.Second() {
|
||||
resetTokenUsedAtUTC := resetToken.UsedAt.UTC()
|
||||
if resetTokenUsedAtUTC.Year() != usedAt.Year() ||
|
||||
resetTokenUsedAtUTC.Month() != usedAt.Month() ||
|
||||
resetTokenUsedAtUTC.Day() != usedAt.Day() ||
|
||||
resetTokenUsedAtUTC.Hour() != usedAt.Hour() ||
|
||||
resetTokenUsedAtUTC.Minute() != usedAt.Minute() ||
|
||||
resetTokenUsedAtUTC.Second() != usedAt.Second() {
|
||||
t.Errorf("used_at should be %+v but got: %+v", usedAt, resetToken.UsedAt)
|
||||
}
|
||||
})
|
||||
|
|
@ -862,13 +863,13 @@ func TestCreateResetToken(t *testing.T) {
|
|||
// Test
|
||||
assert.StatusCodeEquals(t, res, http.StatusFound, "Status code mismtach")
|
||||
|
||||
var tokenCount int
|
||||
var tokenCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Token{}).Count(&tokenCount), "counting tokens")
|
||||
|
||||
var resetToken database.Token
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ? AND type = ?", u.ID, database.TokenTypeResetPassword).First(&resetToken), "finding reset token")
|
||||
|
||||
assert.Equal(t, tokenCount, 1, "reset_token count mismatch")
|
||||
assert.Equal(t, tokenCount, int64(1), "reset_token count mismatch")
|
||||
assert.NotEqual(t, resetToken.Value, nil, "reset_token value mismatch")
|
||||
assert.Equal(t, resetToken.UsedAt, (*time.Time)(nil), "reset_token UsedAt mismatch")
|
||||
})
|
||||
|
|
@ -896,9 +897,9 @@ func TestCreateResetToken(t *testing.T) {
|
|||
// Test
|
||||
assert.StatusCodeEquals(t, res, http.StatusOK, "Status code mismtach")
|
||||
|
||||
var tokenCount int
|
||||
var tokenCount int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Token{}).Count(&tokenCount), "counting tokens")
|
||||
assert.Equal(t, tokenCount, 0, "reset_token count mismatch")
|
||||
assert.Equal(t, tokenCount, int64(0), "reset_token count mismatch")
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -1126,14 +1127,14 @@ func TestVerifyEmail(t *testing.T) {
|
|||
|
||||
var account database.Account
|
||||
var token database.Token
|
||||
var tokenCount int
|
||||
var tokenCount int64
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ?", user.ID).First(&account), "finding account")
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ? AND type = ?", user.ID, database.TokenTypeEmailVerification).First(&token), "finding token")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Token{}).Count(&tokenCount), "counting token")
|
||||
|
||||
assert.Equal(t, account.EmailVerified, true, "email_verified mismatch")
|
||||
assert.NotEqual(t, token.Value, "", "token value should not have been updated")
|
||||
assert.Equal(t, tokenCount, 1, "token count mismatch")
|
||||
assert.Equal(t, tokenCount, int64(1), "token count mismatch")
|
||||
assert.NotEqual(t, token.UsedAt, (*time.Time)(nil), "token should have been used")
|
||||
})
|
||||
|
||||
|
|
@ -1168,14 +1169,14 @@ func TestVerifyEmail(t *testing.T) {
|
|||
|
||||
var account database.Account
|
||||
var token database.Token
|
||||
var tokenCount int
|
||||
var tokenCount int64
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ?", user.ID).First(&account), "finding account")
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ? AND type = ?", user.ID, database.TokenTypeEmailVerification).First(&token), "finding token")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Token{}).Count(&tokenCount), "counting token")
|
||||
|
||||
assert.Equal(t, account.EmailVerified, false, "email_verified mismatch")
|
||||
assert.NotEqual(t, token.UsedAt, nil, "token used_at mismatch")
|
||||
assert.Equal(t, tokenCount, 1, "token count mismatch")
|
||||
assert.Equal(t, tokenCount, int64(1), "token count mismatch")
|
||||
assert.NotEqual(t, token.UsedAt, (*time.Time)(nil), "token should have been used")
|
||||
})
|
||||
|
||||
|
|
@ -1209,13 +1210,13 @@ func TestVerifyEmail(t *testing.T) {
|
|||
|
||||
var account database.Account
|
||||
var token database.Token
|
||||
var tokenCount int
|
||||
var tokenCount int64
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ?", user.ID).First(&account), "finding account")
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ? AND type = ?", user.ID, database.TokenTypeEmailVerification).First(&token), "finding token")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Token{}).Count(&tokenCount), "counting token")
|
||||
|
||||
assert.Equal(t, account.EmailVerified, false, "email_verified mismatch")
|
||||
assert.Equal(t, tokenCount, 1, "token count mismatch")
|
||||
assert.Equal(t, tokenCount, int64(1), "token count mismatch")
|
||||
assert.Equal(t, token.UsedAt, (*time.Time)(nil), "token should have not been used")
|
||||
})
|
||||
|
||||
|
|
@ -1250,13 +1251,13 @@ func TestVerifyEmail(t *testing.T) {
|
|||
|
||||
var account database.Account
|
||||
var token database.Token
|
||||
var tokenCount int
|
||||
var tokenCount int64
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ?", user.ID).First(&account), "finding account")
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ? AND type = ?", user.ID, database.TokenTypeEmailVerification).First(&token), "finding token")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Token{}).Count(&tokenCount), "counting token")
|
||||
|
||||
assert.Equal(t, account.EmailVerified, true, "email_verified mismatch")
|
||||
assert.Equal(t, tokenCount, 1, "token count mismatch")
|
||||
assert.Equal(t, tokenCount, int64(1), "token count mismatch")
|
||||
assert.Equal(t, token.UsedAt, (*time.Time)(nil), "token should have not been used")
|
||||
})
|
||||
}
|
||||
|
|
@ -1286,14 +1287,14 @@ func TestCreateVerificationToken(t *testing.T) {
|
|||
|
||||
var account database.Account
|
||||
var token database.Token
|
||||
var tokenCount int
|
||||
var tokenCount int64
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ?", user.ID).First(&account), "finding account")
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ? AND type = ?", user.ID, database.TokenTypeEmailVerification).First(&token), "finding token")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Token{}).Count(&tokenCount), "counting token")
|
||||
|
||||
assert.Equal(t, account.EmailVerified, false, "email_verified should not have been updated")
|
||||
assert.NotEqual(t, token.Value, "", "token Value mismatch")
|
||||
assert.Equal(t, tokenCount, 1, "token count mismatch")
|
||||
assert.Equal(t, tokenCount, int64(1), "token count mismatch")
|
||||
assert.Equal(t, token.UsedAt, (*time.Time)(nil), "token UsedAt mismatch")
|
||||
assert.Equal(t, len(emailBackend.Emails), 1, "email queue count mismatch")
|
||||
})
|
||||
|
|
@ -1320,11 +1321,11 @@ func TestCreateVerificationToken(t *testing.T) {
|
|||
assert.StatusCodeEquals(t, res, http.StatusConflict, "Status code mismatch")
|
||||
|
||||
var account database.Account
|
||||
var tokenCount int
|
||||
var tokenCount int64
|
||||
testutils.MustExec(t, testutils.DB.Where("user_id = ?", user.ID).First(&account), "finding account")
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Token{}).Count(&tokenCount), "counting token")
|
||||
|
||||
assert.Equal(t, account.EmailVerified, true, "email_verified should not have been updated")
|
||||
assert.Equal(t, tokenCount, 0, "token count mismatch")
|
||||
assert.Equal(t, tokenCount, int64(0), "token count mismatch")
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,9 @@ package database
|
|||
|
||||
import (
|
||||
"github.com/dnote/dnote/pkg/server/config"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
// Use postgres
|
||||
_ "github.com/lib/pq"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -39,22 +37,22 @@ func InitSchema(db *gorm.DB) {
|
|||
}
|
||||
|
||||
if err := db.AutoMigrate(
|
||||
Note{},
|
||||
Book{},
|
||||
User{},
|
||||
Account{},
|
||||
Notification{},
|
||||
Token{},
|
||||
EmailPreference{},
|
||||
Session{},
|
||||
).Error; err != nil {
|
||||
&User{},
|
||||
&Account{},
|
||||
&Book{},
|
||||
&Note{},
|
||||
&Notification{},
|
||||
&Token{},
|
||||
&EmailPreference{},
|
||||
&Session{},
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Open initializes the database connection
|
||||
func Open(c config.Config) *gorm.DB {
|
||||
db, err := gorm.Open("postgres", c.DB.GetConnectionStr())
|
||||
db, err := gorm.Open(postgres.Open(c.DB.GetConnectionStr()), &gorm.Config{})
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "opening database conection"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import (
|
|||
"net/http"
|
||||
|
||||
"github.com/dnote/dnote/pkg/server/database/migrations"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rubenv/sql-migrate"
|
||||
)
|
||||
|
|
@ -36,7 +36,12 @@ func Migrate(db *gorm.DB) error {
|
|||
|
||||
migrate.SetTable(MigrationTableName)
|
||||
|
||||
n, err := migrate.Exec(db.DB(), "postgres", migrations, migrate.Up)
|
||||
sqlDB, err := db.DB()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "getting underlying sql.DB")
|
||||
}
|
||||
|
||||
n, err := migrate.Exec(sqlDB, "postgres", migrations, migrate.Up)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "running migrations")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,12 @@ func main() {
|
|||
|
||||
migrate.SetTable("migrations")
|
||||
|
||||
n, err := migrate.Exec(db.DB(), "postgres", migrations, migrate.Up)
|
||||
sqlDB, err := db.DB()
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "getting underlying sql.DB"))
|
||||
}
|
||||
|
||||
n, err := migrate.Exec(sqlDB, "postgres", migrations, migrate.Up)
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "executing migrations"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
|
||||
// Model is the base model definition
|
||||
type Model struct {
|
||||
ID int `gorm:"primary_key" json:"-"`
|
||||
ID int `gorm:"primaryKey" json:"-"`
|
||||
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
|
@ -32,10 +32,10 @@ type Model struct {
|
|||
// Book is a model for a book
|
||||
type Book struct {
|
||||
Model
|
||||
UUID string `json:"uuid" gorm:"index;type:uuid;default:uuid_generate_v4()"`
|
||||
UUID string `json:"uuid" gorm:"uniqueIndex;type:uuid;default:uuid_generate_v4()"`
|
||||
UserID int `json:"user_id" gorm:"index"`
|
||||
Label string `json:"label" gorm:"index"`
|
||||
Notes []Note `json:"notes" gorm:"foreignkey:book_uuid"`
|
||||
Notes []Note `json:"notes" gorm:"foreignKey:BookUUID;references:UUID"`
|
||||
AddedOn int64 `json:"added_on"`
|
||||
EditedOn int64 `json:"edited_on"`
|
||||
USN int `json:"-" gorm:"index"`
|
||||
|
|
@ -47,7 +47,7 @@ type Book struct {
|
|||
type Note struct {
|
||||
Model
|
||||
UUID string `json:"uuid" gorm:"index;type:uuid;default:uuid_generate_v4()"`
|
||||
Book Book `json:"book" gorm:"foreignkey:BookUUID"`
|
||||
Book Book `json:"book" gorm:"foreignKey:BookUUID;references:UUID"`
|
||||
User User `json:"user"`
|
||||
UserID int `json:"user_id" gorm:"index"`
|
||||
BookUUID string `json:"book_uuid" gorm:"index;type:uuid"`
|
||||
|
|
@ -66,7 +66,7 @@ type Note struct {
|
|||
type User struct {
|
||||
Model
|
||||
UUID string `json:"uuid" gorm:"type:uuid;index;default:uuid_generate_v4()"`
|
||||
Account Account
|
||||
Account Account `gorm:"foreignKey:UserID"`
|
||||
LastLoginAt *time.Time `json:"-"`
|
||||
MaxUSN int `json:"-" gorm:"default:0"`
|
||||
Cloud bool `json:"-" gorm:"default:false"`
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// PreloadNote preloads the associations for a notes for the given query
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
"github.com/dnote/dnote/pkg/clock"
|
||||
"github.com/dnote/dnote/pkg/server/config"
|
||||
"github.com/dnote/dnote/pkg/server/mailer"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/robfig/cron"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"github.com/dnote/dnote/pkg/server/config"
|
||||
"github.com/dnote/dnote/pkg/server/mailer"
|
||||
"github.com/dnote/dnote/pkg/server/testutils"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import (
|
|||
"github.com/dnote/dnote/pkg/server/config"
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/dnote/dnote/pkg/server/mailer"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/joho/godotenv"
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
|
@ -122,7 +122,12 @@ type Context struct {
|
|||
func main() {
|
||||
c := config.Load()
|
||||
db := database.Open(c)
|
||||
defer db.Close()
|
||||
defer func() {
|
||||
sqlDB, err := db.DB()
|
||||
if err == nil {
|
||||
sqlDB.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
log.Println("Email template development server running on http://127.0.0.1:2300")
|
||||
|
||||
|
|
|
|||
|
|
@ -21,10 +21,11 @@ package mailer
|
|||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/pkg/errors"
|
||||
pkgErrors "github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func generateRandomToken(bits int) (string, error) {
|
||||
|
|
@ -32,7 +33,7 @@ func generateRandomToken(bits int) (string, error) {
|
|||
|
||||
_, err := rand.Read(b)
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "generating random bytes")
|
||||
return "", pkgErrors.Wrap(err, "generating random bytes")
|
||||
}
|
||||
|
||||
return base64.URLEncoding.EncodeToString(b), nil
|
||||
|
|
@ -42,28 +43,28 @@ func generateRandomToken(bits int) (string, error) {
|
|||
// by first looking up any unused record and creating one if none exists.
|
||||
func GetToken(db *gorm.DB, userID int, kind string) (database.Token, error) {
|
||||
var tok database.Token
|
||||
conn := db.
|
||||
err := db.
|
||||
Where("user_id = ? AND type =? AND used_at IS NULL", userID, kind).
|
||||
First(&tok)
|
||||
First(&tok).Error
|
||||
|
||||
tokenVal, err := generateRandomToken(16)
|
||||
if err != nil {
|
||||
return tok, errors.Wrap(err, "generating token value")
|
||||
tokenVal, genErr := generateRandomToken(16)
|
||||
if genErr != nil {
|
||||
return tok, pkgErrors.Wrap(genErr, "generating token value")
|
||||
}
|
||||
|
||||
if conn.RecordNotFound() {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
tok = database.Token{
|
||||
UserID: userID,
|
||||
Type: kind,
|
||||
Value: tokenVal,
|
||||
}
|
||||
if err := db.Save(&tok).Error; err != nil {
|
||||
return tok, errors.Wrap(err, "saving token")
|
||||
return tok, pkgErrors.Wrap(err, "saving token")
|
||||
}
|
||||
|
||||
return tok, nil
|
||||
} else if err := conn.Error; err != nil {
|
||||
return tok, errors.Wrap(err, "finding token")
|
||||
} else if err != nil {
|
||||
return tok, pkgErrors.Wrap(err, "finding token")
|
||||
}
|
||||
|
||||
return tok, nil
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ import (
|
|||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/dnote/dnote/pkg/server/job"
|
||||
"github.com/dnote/dnote/pkg/server/mailer"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
|
@ -40,7 +41,7 @@ import (
|
|||
var port = flag.String("port", "3000", "port to connect to")
|
||||
|
||||
func initDB(c config.Config) *gorm.DB {
|
||||
db, err := gorm.Open("postgres", c.DB.GetConnectionStr())
|
||||
db, err := gorm.Open(postgres.Open(c.DB.GetConnectionStr()), &gorm.Config{})
|
||||
if err != nil {
|
||||
panic(errors.Wrap(err, "opening database connection"))
|
||||
}
|
||||
|
|
@ -79,7 +80,12 @@ func startCmd() {
|
|||
cfg.SetAssetBaseURL("/static")
|
||||
|
||||
app := initApp(cfg)
|
||||
defer app.DB.Close()
|
||||
defer func() {
|
||||
sqlDB, err := app.DB.DB()
|
||||
if err == nil {
|
||||
sqlDB.Close()
|
||||
}
|
||||
}()
|
||||
|
||||
if err := database.Migrate(app.DB); err != nil {
|
||||
panic(errors.Wrap(err, "running migrations"))
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package middleware
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
|
@ -29,8 +30,8 @@ import (
|
|||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/dnote/dnote/pkg/server/helpers"
|
||||
"github.com/dnote/dnote/pkg/server/log"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
pkgErrors "github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func authWithToken(db *gorm.DB, r *http.Request, tokenType string, p *AuthParams) (database.User, database.Token, bool, error) {
|
||||
|
|
@ -43,11 +44,11 @@ func authWithToken(db *gorm.DB, r *http.Request, tokenType string, p *AuthParams
|
|||
return user, token, false, nil
|
||||
}
|
||||
|
||||
conn := db.Where("value = ? AND type = ?", tokenValue, tokenType).First(&token)
|
||||
if conn.RecordNotFound() {
|
||||
err := db.Where("value = ? AND type = ?", tokenValue, tokenType).First(&token).Error
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return user, token, false, nil
|
||||
} else if err := conn.Error; err != nil {
|
||||
return user, token, false, errors.Wrap(err, "finding token")
|
||||
} else if err != nil {
|
||||
return user, token, false, pkgErrors.Wrap(err, "finding token")
|
||||
}
|
||||
|
||||
if token.UsedAt != nil && time.Since(*token.UsedAt).Minutes() > 10 {
|
||||
|
|
@ -55,7 +56,7 @@ func authWithToken(db *gorm.DB, r *http.Request, tokenType string, p *AuthParams
|
|||
}
|
||||
|
||||
if err := db.Where("id = ?", token.UserID).First(&user).Error; err != nil {
|
||||
return user, token, false, errors.Wrap(err, "finding user")
|
||||
return user, token, false, pkgErrors.Wrap(err, "finding user")
|
||||
}
|
||||
|
||||
return user, token, true, nil
|
||||
|
|
@ -180,31 +181,31 @@ func AuthWithSession(db *gorm.DB, r *http.Request) (database.User, bool, error)
|
|||
|
||||
sessionKey, err := GetCredential(r)
|
||||
if err != nil {
|
||||
return user, false, errors.Wrap(err, "getting credential")
|
||||
return user, false, pkgErrors.Wrap(err, "getting credential")
|
||||
}
|
||||
if sessionKey == "" {
|
||||
return user, false, nil
|
||||
}
|
||||
|
||||
var session database.Session
|
||||
conn := db.Where("key = ?", sessionKey).First(&session)
|
||||
err = db.Where("key = ?", sessionKey).First(&session).Error
|
||||
|
||||
if conn.RecordNotFound() {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return user, false, nil
|
||||
} else if err := conn.Error; err != nil {
|
||||
return user, false, errors.Wrap(err, "finding session")
|
||||
} else if err != nil {
|
||||
return user, false, pkgErrors.Wrap(err, "finding session")
|
||||
}
|
||||
|
||||
if session.ExpiresAt.Before(time.Now()) {
|
||||
return user, false, nil
|
||||
}
|
||||
|
||||
conn = db.Where("id = ?", session.UserID).First(&user)
|
||||
err = db.Where("id = ?", session.UserID).First(&user).Error
|
||||
|
||||
if conn.RecordNotFound() {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return user, false, nil
|
||||
} else if err := conn.Error; err != nil {
|
||||
return user, false, errors.Wrap(err, "finding user from token")
|
||||
} else if err != nil {
|
||||
return user, false, pkgErrors.Wrap(err, "finding user from token")
|
||||
}
|
||||
|
||||
return user, true, nil
|
||||
|
|
|
|||
|
|
@ -19,11 +19,13 @@
|
|||
package operations
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/dnote/dnote/pkg/server/helpers"
|
||||
"github.com/dnote/dnote/pkg/server/permissions"
|
||||
"github.com/jinzhu/gorm"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/gorm"
|
||||
pkgErrors "github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GetNote retrieves a note for the given user
|
||||
|
|
@ -33,16 +35,13 @@ func GetNote(db *gorm.DB, uuid string, user *database.User) (database.Note, bool
|
|||
return zeroNote, false, nil
|
||||
}
|
||||
|
||||
conn := db.Where("notes.uuid = ? AND deleted = ?", uuid, false)
|
||||
conn = database.PreloadNote(conn)
|
||||
|
||||
var note database.Note
|
||||
conn = conn.Find(¬e)
|
||||
err := database.PreloadNote(db.Where("notes.uuid = ? AND deleted = ?", uuid, false)).Find(¬e).Error
|
||||
|
||||
if conn.RecordNotFound() {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return zeroNote, false, nil
|
||||
} else if err := conn.Error; err != nil {
|
||||
return zeroNote, false, errors.Wrap(err, "finding note")
|
||||
} else if err != nil {
|
||||
return zeroNote, false, pkgErrors.Wrap(err, "finding note")
|
||||
}
|
||||
|
||||
if ok := permissions.ViewNote(user, note); !ok {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import (
|
|||
|
||||
"github.com/dnote/dnote/pkg/server/config"
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
|
@ -61,30 +61,31 @@ func InitTestDB() {
|
|||
|
||||
// ClearData deletes all records from the database
|
||||
func ClearData(db *gorm.DB) {
|
||||
if err := db.Delete(&database.Book{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear books"))
|
||||
}
|
||||
if err := db.Delete(&database.Note{}).Error; err != nil {
|
||||
// Delete in order: child tables first, parent tables last
|
||||
if err := db.Where("1 = 1").Delete(&database.Note{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear notes"))
|
||||
}
|
||||
if err := db.Delete(&database.Notification{}).Error; err != nil {
|
||||
if err := db.Where("1 = 1").Delete(&database.Book{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear books"))
|
||||
}
|
||||
if err := db.Where("1 = 1").Delete(&database.Notification{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear notifications"))
|
||||
}
|
||||
if err := db.Delete(&database.User{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear users"))
|
||||
}
|
||||
if err := db.Delete(&database.Account{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear accounts"))
|
||||
}
|
||||
if err := db.Delete(&database.Token{}).Error; err != nil {
|
||||
if err := db.Where("1 = 1").Delete(&database.Token{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear tokens"))
|
||||
}
|
||||
if err := db.Delete(&database.EmailPreference{}).Error; err != nil {
|
||||
if err := db.Where("1 = 1").Delete(&database.EmailPreference{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear email preferences"))
|
||||
}
|
||||
if err := db.Delete(&database.Session{}).Error; err != nil {
|
||||
if err := db.Where("1 = 1").Delete(&database.Session{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear sessions"))
|
||||
}
|
||||
if err := db.Where("1 = 1").Delete(&database.Account{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear accounts"))
|
||||
}
|
||||
if err := db.Where("1 = 1").Delete(&database.User{}).Error; err != nil {
|
||||
panic(errors.Wrap(err, "Failed to clear users"))
|
||||
}
|
||||
}
|
||||
|
||||
// SetupUserData creates and returns a new user for testing purposes
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
"net/http"
|
||||
"regexp"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@ func TestDefaultPageGetData(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestNotePageGetData(t *testing.T) {
|
||||
// Set time.Local to UTC for deterministic test
|
||||
time.Local = time.UTC
|
||||
|
||||
a, err := NewAppShell(testutils.DB, nil)
|
||||
if err != nil {
|
||||
t.Fatal(errors.Wrap(err, "preparing app shell"))
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import (
|
|||
"encoding/base64"
|
||||
|
||||
"github.com/dnote/dnote/pkg/server/database"
|
||||
"github.com/jinzhu/gorm"
|
||||
"gorm.io/gorm"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ func TestCreate(t *testing.T) {
|
|||
}
|
||||
|
||||
// Test
|
||||
var count int
|
||||
var count int64
|
||||
testutils.MustExec(t, testutils.DB.Model(&database.Token{}).Count(&count), "counting token")
|
||||
assert.Equalf(t, count, 1, "error mismatch")
|
||||
assert.Equalf(t, count, int64(1), "error mismatch")
|
||||
|
||||
var tokenRecord database.Token
|
||||
testutils.MustExec(t, testutils.DB.First(&tokenRecord), "finding token")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue