pico
created pr with
97.1
added 97.2
1: fdc255e = 1: fdc255e refactor: remove unused db methods
2: 3f855f6 = 2: 3f855f6 chore: add tests for postgres db impl
3: 7cd29a6 = 3: 7cd29a6 refactor: use sqlx interface
4: acd449e = 4: acd449e chore: add db tags
5: f6ed0d7 = 5: f6ed0d7 refactor: use sqlx
6: 29035c6 = 6: 29035c6 refactor: replace custom sql functions with sqlx
7: d4ea6d9 = 7: d4ea6d9 refactor: inline all sql queries
-: ------- > 8: 4bd37ed refactor: use `select * from` where possible
cmds
checkout latest patchset:
ssh pr.pico.sh print 97 | git am -3checkout any patchset in a patch request:
ssh pr.pico.sh print 97.[rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 97
Patchset
97.1
refactor: remove unused db methods
Eric Bower
→ chore: add tests for postgres db impl
2025-12-18T03:03:10ZEric Bower
refactor: use sqlx interface
2025-12-18T03:17:57ZEric Bower
chore: add db tags
2025-12-18T03:27:57ZEric Bower
refactor: use sqlx
2025-12-18T03:31:25ZEric Bower
refactor: replace custom sql functions with sqlx
2025-12-18T03:43:01ZEric Bower
refactor: inline all sql queries
2025-12-18T03:57:00ZEric Bower
2025-12-18T04:02:50Z
chore: add tests for postgres db impl
Eric Bower
2025-12-18T03:17:57ZSemantic diff summary
71 added,
0 modified,
0 signature changed,
0 removed
across 1 analyzed file
(2 files skipped: unsupported file type)
pkg/db/postgres/storage_test.go
-
function_declarationmustInsertPostadded -
function_declarationTestFindPostsForUseradded -
function_declarationTestFindPopularTagsadded -
function_declarationTestFindFeedItemsByPostIDadded -
function_declarationTestFindUserByNameadded -
function_declarationTestInsertTokenadded -
function_declarationTestFindUserPostsByTagadded -
function_declarationTestVisitUrlNotFoundadded -
function_declarationTestInsertFeedItemsadded -
function_declarationTestInsertTunsEventLogadded -
function_declarationTestFindUserByPubkeyadded -
function_declarationTestFindPostWithFilenameadded -
function_declarationTestUpsertProjectadded -
function_declarationTestInsertAccessLogadded -
function_declarationTestProjectAcl_JSONBRoundtripadded -
function_declarationTestRegisterUser_Successadded -
function_declarationTestRemovePostsadded -
function_declarationTestFindPostsForFeedadded -
function_declarationTestFindPostsByTagadded -
function_declarationTestFeedItemData_JSONBRoundtripadded -
function_declarationTestUpdatePublicKeyadded -
function_declarationTestFindKeysForUseradded -
function_declarationTestReplaceAliasesForPostadded -
function_declarationTestFindUserStatsadded -
function_declarationTestFindTunsEventLogsByAddradded -
function_declarationsetupContainerRuntimeadded -
function_declarationTestRegisterUser_DuplicateNameadded -
function_declarationTestReplaceTagsForPostadded -
function_declarationTestPostData_JSONBRoundtripadded -
function_declarationgetProjectRootadded -
function_declarationsetupTestSchemaadded -
function_declarationTestFindFeatureadded -
function_declarationTestFeatureFlagData_JSONBRoundtripadded -
function_declarationTestInsertPublicKey_Successadded -
function_declarationTestFindPostWithSlugadded -
function_declarationTestFindAllPostsForUseradded -
function_declarationTestFindUsersWithPostadded -
function_declarationTestAddPicoPlusUseradded -
function_declarationTestUpdatePostadded -
function_declarationTestFindTunsEventLogsadded -
function_declarationTestFindAccessLogsByPubkeyadded -
function_declarationTestFindUserForKeyadded -
function_declarationTestInsertPublicKey_Duplicateadded -
function_declarationTestFindVisitSiteListadded -
function_declarationTestInsertFeatureadded -
function_declarationTestHasFeatureForUseradded -
function_declarationTestRegisterUser_DeniedNameadded -
function_declarationTestFindTokensForUseradded -
function_declarationTestFindFeaturesForUseradded -
function_declarationTestFindAccessLogsadded -
function_declarationTestVisitSummaryadded -
function_declarationTestRegisterUser_InvalidNameadded -
function_declarationTestRemoveKeysadded -
function_declarationTestUpsertTokenadded -
function_declarationTestFindPostadded -
function_declarationTestFindUseradded -
function_declarationTestFindUsersadded -
function_declarationTestFindExpiredPostsadded -
function_declarationTestFindPostWithSlug_Aliasadded -
function_declarationTestInsertVisitadded -
function_declarationTestFindProjectByNameadded -
function_declarationTestMainadded -
function_declarationTestFindUserForToken_Validadded -
function_declarationTestFindUserForToken_Expiredadded -
function_declarationTestRemoveTokenadded -
function_declarationTestInsertPostadded -
function_declarationTestFindPostsadded -
function_declarationTestRemoveFeatureadded -
function_declarationcleanupTestDataadded -
function_declarationTestFindPubkeysInAccessLogsadded -
function_declarationTestPaymentHistoryData_JSONBRoundtripadded
+48
-12
go.mod
#
| ... | ... | @@ -55,6 +53,8 @@ require ( | |
| 55 | 53 | github.com/prometheus/client_golang v1.22.0 | |
| 56 | 54 | github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 | |
| 57 | 55 | github.com/simplesurance/go-ip-anonymizer v0.0.0-20200429124537-35a880f8e87d | |
| 56 | + | github.com/testcontainers/testcontainers-go v0.40.0 | |
| 57 | + | github.com/testcontainers/testcontainers-go/modules/postgres v0.40.0 | |
| 58 | 58 | github.com/x-way/crawlerdetect v0.2.28 | |
| 59 | 59 | github.com/yuin/goldmark v1.7.8 | |
| 60 | 60 | github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc |
| ... | ... | @@ -62,7 +62,7 @@ require ( | |
| 62 | 62 | go.abhg.dev/goldmark/anchor v0.2.0 | |
| 63 | 63 | go.abhg.dev/goldmark/hashtag v0.3.1 | |
| 64 | 64 | go.abhg.dev/goldmark/toc v0.11.0 | |
| 65 | - | golang.org/x/crypto v0.38.0 | |
| 65 | + | golang.org/x/crypto v0.43.0 | |
| 66 | 66 | google.golang.org/protobuf v1.36.6 | |
| 67 | 67 | gopkg.in/yaml.v2 v2.4.0 | |
| 68 | 68 | modernc.org/sqlite v1.36.2 |
| ... | ... | @@ -71,9 +71,10 @@ require ( | |
| 71 | 71 | require ( | |
| 72 | 72 | cel.dev/expr v0.22.1 // indirect | |
| 73 | 73 | codeberg.org/emersion/go-scfg v0.1.0 // indirect | |
| 74 | - | dario.cat/mergo v1.0.1 // indirect | |
| 74 | + | dario.cat/mergo v1.0.2 // indirect | |
| 75 | 75 | filippo.io/edwards25519 v1.1.0 // indirect | |
| 76 | 76 | github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect | |
| 77 | + | github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect | |
| 77 | 78 | github.com/KimMachineGun/automemlimit v0.7.1 // indirect | |
| 78 | 79 | github.com/Masterminds/goutils v1.1.1 // indirect | |
| 79 | 80 | github.com/Masterminds/semver/v3 v3.3.1 // indirect |
| ... | ... | @@ -98,13 +99,19 @@ require ( | |
| 98 | 99 | github.com/caddyserver/certmagic v0.23.0 // indirect | |
| 99 | 100 | github.com/caddyserver/zerossl v0.1.3 // indirect | |
| 100 | 101 | github.com/ccoveille/go-safecast v1.6.1 // indirect | |
| 102 | + | github.com/cenkalti/backoff/v4 v4.3.0 // indirect | |
| 101 | 103 | github.com/cespare/xxhash v1.1.0 // indirect | |
| 102 | 104 | github.com/cespare/xxhash/v2 v2.3.0 // indirect | |
| 103 | 105 | github.com/chzyer/readline v1.5.1 // indirect | |
| 104 | 106 | github.com/cloudflare/circl v1.6.0 // indirect | |
| 107 | + | github.com/containerd/errdefs v1.0.0 // indirect | |
| 108 | + | github.com/containerd/errdefs/pkg v0.3.0 // indirect | |
| 109 | + | github.com/containerd/log v0.1.0 // indirect | |
| 110 | + | github.com/containerd/platforms v0.2.1 // indirect | |
| 105 | 111 | github.com/coreos/go-oidc/v3 v3.13.0 // indirect | |
| 106 | 112 | github.com/coreos/go-semver v0.3.1 // indirect | |
| 107 | 113 | github.com/coreos/go-systemd/v22 v22.5.0 // indirect | |
| 114 | + | github.com/cpuguy83/dockercfg v0.3.2 // indirect | |
| 108 | 115 | github.com/cpuguy83/go-md2man/v2 v2.0.6 // indirect | |
| 109 | 116 | github.com/darkweak/go-esi v0.0.6 // indirect | |
| 110 | 117 | github.com/darkweak/storages/badger v0.0.14 // indirect |
| ... | ... | @@ -115,6 +122,7 @@ require ( | |
| 115 | 122 | github.com/darkweak/storages/otter v0.0.14 // indirect | |
| 116 | 123 | github.com/darkweak/storages/redis v0.0.14 // indirect | |
| 117 | 124 | github.com/darkweak/storages/simplefs v0.0.14 // indirect | |
| 125 | + | github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | |
| 118 | 126 | github.com/delthas/go-libnp v0.1.0 // indirect | |
| 119 | 127 | github.com/delthas/go-localeinfo v0.1.0 // indirect | |
| 120 | 128 | github.com/dgraph-io/badger v1.6.2 // indirect |
| ... | ... | @@ -124,7 +132,11 @@ require ( | |
| 124 | 132 | github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da // indirect | |
| 125 | 133 | github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect | |
| 126 | 134 | github.com/disintegration/imaging v1.6.2 // indirect | |
| 135 | + | github.com/distribution/reference v0.6.0 // indirect | |
| 127 | 136 | github.com/dlclark/regexp2 v1.11.5 // indirect | |
| 137 | + | github.com/docker/docker v28.5.1+incompatible // indirect | |
| 138 | + | github.com/docker/go-connections v0.6.0 // indirect | |
| 139 | + | github.com/docker/go-units v0.5.0 // indirect | |
| 128 | 140 | github.com/dolthub/maphash v0.1.0 // indirect | |
| 129 | 141 | github.com/dsoprea/go-exif v0.0.0-20230826092837-6579e82b732d // indirect | |
| 130 | 142 | github.com/dsoprea/go-exif/v2 v2.0.0-20230826092837-6579e82b732d // indirect |
| ... | ... | @@ -134,6 +146,8 @@ require ( | |
| 134 | 146 | github.com/dsoprea/go-png-image-structure v0.0.0-20210512210324-29b889a6093d // indirect | |
| 135 | 147 | github.com/dsoprea/go-utility v0.0.0-20221003172846-a3e1774ef349 // indirect | |
| 136 | 148 | github.com/dustin/go-humanize v1.0.1 // indirect | |
| 149 | + | github.com/ebitengine/purego v0.8.4 // indirect | |
| 150 | + | github.com/felixge/httpsnoop v1.0.4 // indirect | |
| 137 | 151 | github.com/forPelevin/gomoji v1.3.0 // indirect | |
| 138 | 152 | github.com/francoispqt/gojay v1.2.13 // indirect | |
| 139 | 153 | github.com/gammazero/deque v1.0.0 // indirect |
| ... | ... | @@ -143,6 +157,8 @@ require ( | |
| 143 | 157 | github.com/go-ini/ini v1.67.0 // indirect | |
| 144 | 158 | github.com/go-jose/go-jose/v3 v3.0.4 // indirect | |
| 145 | 159 | github.com/go-jose/go-jose/v4 v4.0.5 // indirect | |
| 160 | + | github.com/go-logr/logr v1.4.2 // indirect | |
| 161 | + | github.com/go-logr/stdr v1.2.2 // indirect | |
| 146 | 162 | github.com/go-ole/go-ole v1.3.0 // indirect | |
| 147 | 163 | github.com/go-redis/redis/v8 v8.11.5 // indirect | |
| 148 | 164 | github.com/go-sql-driver/mysql v1.9.1 // indirect |
| ... | ... | @@ -186,6 +202,7 @@ require ( | |
| 186 | 202 | github.com/kr/text v0.2.0 // indirect | |
| 187 | 203 | github.com/libdns/libdns v1.0.0-beta.1 // indirect | |
| 188 | 204 | github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect | |
| 205 | + | github.com/magiconair/properties v1.8.10 // indirect | |
| 189 | 206 | github.com/manifoldco/promptui v0.9.0 // indirect | |
| 190 | 207 | github.com/maruel/natural v1.1.1 // indirect | |
| 191 | 208 | github.com/mattn/go-colorable v0.1.14 // indirect |
| ... | ... | @@ -204,8 +221,16 @@ require ( | |
| 204 | 221 | github.com/mitchellh/reflectwalk v1.0.2 // indirect | |
| 205 | 222 | github.com/mmcdole/goxpp v1.1.1 // indirect | |
| 206 | 223 | github.com/mmcloughlin/md4 v0.1.2 // indirect | |
| 224 | + | github.com/moby/docker-image-spec v1.3.1 // indirect | |
| 225 | + | github.com/moby/go-archive v0.1.0 // indirect | |
| 226 | + | github.com/moby/patternmatcher v0.6.0 // indirect | |
| 227 | + | github.com/moby/sys/sequential v0.6.0 // indirect | |
| 228 | + | github.com/moby/sys/user v0.4.0 // indirect | |
| 229 | + | github.com/moby/sys/userns v0.1.0 // indirect | |
| 230 | + | github.com/moby/term v0.5.0 // indirect | |
| 207 | 231 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | |
| 208 | 232 | github.com/modern-go/reflect2 v1.0.2 // indirect | |
| 233 | + | github.com/morikuni/aec v1.0.0 // indirect | |
| 209 | 234 | github.com/mschoch/smat v0.2.0 // indirect | |
| 210 | 235 | github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | |
| 211 | 236 | github.com/nats-io/nats.go v1.40.1 // indirect |
| ... | ... | @@ -215,10 +240,13 @@ require ( | |
| 215 | 240 | github.com/neurosnap/go-jpeg-image-structure v0.0.0-20221010133817-70b1c1ff679e // indirect | |
| 216 | 241 | github.com/nutsdb/nutsdb v1.0.4 // indirect | |
| 217 | 242 | github.com/onsi/ginkgo/v2 v2.23.3 // indirect | |
| 243 | + | github.com/opencontainers/go-digest v1.0.0 // indirect | |
| 244 | + | github.com/opencontainers/image-spec v1.1.1 // indirect | |
| 218 | 245 | github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect | |
| 219 | 246 | github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect | |
| 220 | 247 | github.com/pierrec/lz4/v4 v4.1.22 // indirect | |
| 221 | 248 | github.com/pkg/errors v0.9.1 // indirect | |
| 249 | + | github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect | |
| 222 | 250 | github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect | |
| 223 | 251 | github.com/pquerna/cachecontrol v0.2.0 // indirect | |
| 224 | 252 | github.com/prometheus/client_model v0.6.2 // indirect |
| ... | ... | @@ -238,9 +266,11 @@ require ( | |
| 238 | 266 | github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect | |
| 239 | 267 | github.com/secure-io/sio-go v0.3.1 // indirect | |
| 240 | 268 | github.com/shirou/gopsutil/v3 v3.24.5 // indirect | |
| 269 | + | github.com/shirou/gopsutil/v4 v4.25.6 // indirect | |
| 241 | 270 | github.com/shoenig/go-m1cpu v0.1.6 // indirect | |
| 242 | 271 | github.com/shopspring/decimal v1.4.0 // indirect | |
| 243 | 272 | github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect | |
| 273 | + | github.com/sirupsen/logrus v1.9.3 // indirect | |
| 244 | 274 | github.com/slackhq/nebula v1.9.5 // indirect | |
| 245 | 275 | github.com/smallstep/certificates v0.28.3 // indirect | |
| 246 | 276 | github.com/smallstep/cli-utils v0.12.1 // indirect |
| ... | ... | @@ -254,6 +284,7 @@ require ( | |
| 254 | 284 | github.com/spf13/cobra v1.9.1 // indirect | |
| 255 | 285 | github.com/spf13/pflag v1.0.6 // indirect | |
| 256 | 286 | github.com/stoewer/go-strcase v1.3.0 // indirect | |
| 287 | + | github.com/stretchr/testify v1.11.1 // indirect | |
| 257 | 288 | github.com/tailscale/tscert v0.0.0-20240608151842-d3f834017e53 // indirect | |
| 258 | 289 | github.com/tidwall/btree v1.7.0 // indirect | |
| 259 | 290 | github.com/tidwall/gjson v1.17.0 // indirect |
| ... | ... | @@ -276,6 +307,11 @@ require ( | |
| 276 | 307 | go.etcd.io/etcd/client/pkg/v3 v3.5.21 // indirect | |
| 277 | 308 | go.etcd.io/etcd/client/v3 v3.5.21 // indirect | |
| 278 | 309 | go.opencensus.io v0.24.0 // indirect | |
| 310 | + | go.opentelemetry.io/auto/sdk v1.1.0 // indirect | |
| 311 | + | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect | |
| 312 | + | go.opentelemetry.io/otel v1.35.0 // indirect | |
| 313 | + | go.opentelemetry.io/otel/metric v1.35.0 // indirect | |
| 314 | + | go.opentelemetry.io/otel/trace v1.35.0 // indirect | |
| 279 | 315 | go.step.sm/crypto v0.60.0 // indirect | |
| 280 | 316 | go.uber.org/automaxprocs v1.6.0 // indirect | |
| 281 | 317 | go.uber.org/mock v0.5.0 // indirect |
| ... | ... | @@ -285,15 +321,15 @@ require ( | |
| 285 | 321 | golang.org/x/crypto/x509roots/fallback v0.0.0-20250317152234-d0a798f77473 // indirect | |
| 286 | 322 | golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect | |
| 287 | 323 | golang.org/x/image v0.25.0 // indirect | |
| 288 | - | golang.org/x/mod v0.24.0 // indirect | |
| 289 | - | golang.org/x/net v0.38.0 // indirect | |
| 324 | + | golang.org/x/mod v0.28.0 // indirect | |
| 325 | + | golang.org/x/net v0.45.0 // indirect | |
| 290 | 326 | golang.org/x/oauth2 v0.28.0 // indirect | |
| 291 | - | golang.org/x/sync v0.14.0 // indirect | |
| 292 | - | golang.org/x/sys v0.33.0 // indirect | |
| 293 | - | golang.org/x/term v0.32.0 // indirect | |
| 294 | - | golang.org/x/text v0.25.0 // indirect | |
| 327 | + | golang.org/x/sync v0.17.0 // indirect | |
| 328 | + | golang.org/x/sys v0.37.0 // indirect | |
| 329 | + | golang.org/x/term v0.36.0 // indirect | |
| 330 | + | golang.org/x/text v0.30.0 // indirect | |
| 295 | 331 | golang.org/x/time v0.11.0 // indirect | |
| 296 | - | golang.org/x/tools v0.31.0 // indirect | |
| 332 | + | golang.org/x/tools v0.37.0 // indirect | |
| 297 | 333 | google.golang.org/genproto/googleapis/api v0.0.0-20250324211829-b45e905df463 // indirect | |
| 298 | 334 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 // indirect | |
| 299 | 335 | google.golang.org/grpc v1.71.0 // indirect |
+101
-26
go.sum
#
| ... | ... | @@ -20,8 +20,8 @@ cloud.google.com/go/longrunning v0.6.6 h1:XJNDo5MUfMM05xK3ewpbSdmt7R2Zw+aQEMbdQR | |
| 20 | 20 | cloud.google.com/go/longrunning v0.6.6/go.mod h1:hyeGJUrPHcx0u2Uu1UFSoYZLn4lkMrccJig0t4FI7yw= | |
| 21 | 21 | codeberg.org/emersion/go-scfg v0.1.0 h1:6dnGU0ZI4gX+O5rMjwhoaySItzHG710eXL5TIQKl+uM= | |
| 22 | 22 | codeberg.org/emersion/go-scfg v0.1.0/go.mod h1:0nooW1ufBB4SlJEdTtiVN9Or+bnNM1icOkQ6Tbrq6O0= | |
| 23 | - | dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= | |
| 24 | - | dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= | |
| 23 | + | dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= | |
| 24 | + | dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= | |
| 25 | 25 | dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= | |
| 26 | 26 | dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= | |
| 27 | 27 | dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= |
| ... | ... | @@ -33,8 +33,12 @@ git.sr.ht/~delthas/senpai v0.4.0 h1:G1cycL0ARqYkqOErjEx/7Cneqykq3POfCsMYnpkWhUY= | |
| 33 | 33 | git.sr.ht/~delthas/senpai v0.4.0/go.mod h1:mzdu4o3wANA6cYzRnrz3w+uGPHA2z3j02JDrr/M3Myc= | |
| 34 | 34 | git.sr.ht/~rockorager/vaxis v0.14.1-0.20250527151737-5530f9f4bcf6 h1:lmSD6ksbKNMLdhT8R2k5FQPz8ObjslX8NkCM6z1kifI= | |
| 35 | 35 | git.sr.ht/~rockorager/vaxis v0.14.1-0.20250527151737-5530f9f4bcf6/go.mod h1:h94aKek3frIV1hJbdXjqnBqaLkbWXvV+UxAsQHg9bns= | |
| 36 | + | github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 h1:He8afgbRMd7mFxO99hRNu+6tazq8nFF9lIwo9JFroBk= | |
| 37 | + | github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= | |
| 36 | 38 | github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= | |
| 37 | 39 | github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= | |
| 40 | + | github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= | |
| 41 | + | github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= | |
| 38 | 42 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= | |
| 39 | 43 | github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= | |
| 40 | 44 | github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= |
| ... | ... | @@ -146,6 +150,8 @@ github.com/caddyserver/zerossl v0.1.3 h1:onS+pxp3M8HnHpN5MMbOMyNjmTheJyWRaZYwn+Y | |
| 146 | 150 | github.com/caddyserver/zerossl v0.1.3/go.mod h1:CxA0acn7oEGO6//4rtrRjYgEoa4MFw/XofZnrYwGqG4= | |
| 147 | 151 | github.com/ccoveille/go-safecast v1.6.1 h1:Nb9WMDR8PqhnKCVs2sCB+OqhohwO5qaXtCviZkIff5Q= | |
| 148 | 152 | github.com/ccoveille/go-safecast v1.6.1/go.mod h1:QqwNjxQ7DAqY0C721OIO9InMk9zCwcsO7tnRuHytad8= | |
| 153 | + | github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= | |
| 154 | + | github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= | |
| 149 | 155 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= | |
| 150 | 156 | github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= | |
| 151 | 157 | github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= |
| ... | ... | @@ -170,6 +176,14 @@ github.com/cloudflare/circl v1.6.0/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZ | |
| 170 | 176 | github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= | |
| 171 | 177 | github.com/containerd/console v1.0.4 h1:F2g4+oChYvBTsASRTz8NP6iIAi97J3TtSAsLbIFn4ro= | |
| 172 | 178 | github.com/containerd/console v1.0.4/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= | |
| 179 | + | github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= | |
| 180 | + | github.com/containerd/errdefs v1.0.0/go.mod h1:+YBYIdtsnF4Iw6nWZhJcqGSg/dwvV7tyJ/kCkyJ2k+M= | |
| 181 | + | github.com/containerd/errdefs/pkg v0.3.0 h1:9IKJ06FvyNlexW690DXuQNx2KA2cUJXx151Xdx3ZPPE= | |
| 182 | + | github.com/containerd/errdefs/pkg v0.3.0/go.mod h1:NJw6s9HwNuRhnjJhM7pylWwMyAkmCQvQ4GpJHEqRLVk= | |
| 183 | + | github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= | |
| 184 | + | github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= | |
| 185 | + | github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A= | |
| 186 | + | github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw= | |
| 173 | 187 | github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= | |
| 174 | 188 | github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= | |
| 175 | 189 | github.com/coreos/go-oidc/v3 v3.13.0 h1:M66zd0pcc5VxvBNM4pB331Wrsanby+QomQYjN8HamW8= |
| ... | ... | @@ -180,11 +194,15 @@ github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03V | |
| 180 | 194 | github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= | |
| 181 | 195 | github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= | |
| 182 | 196 | github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= | |
| 197 | + | github.com/cpuguy83/dockercfg v0.3.2 h1:DlJTyZGBDlXqUZ2Dk2Q3xHs/FtnooJJVaad2S9GKorA= | |
| 198 | + | github.com/cpuguy83/dockercfg v0.3.2/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= | |
| 183 | 199 | github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= | |
| 184 | 200 | github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= | |
| 185 | 201 | github.com/cpuguy83/go-md2man/v2 v2.0.6 h1:XJtiaUW6dEEqVuZiMTn1ldk455QWwEIsMIJlo5vtkx0= | |
| 186 | 202 | github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= | |
| 187 | 203 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= | |
| 204 | + | github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= | |
| 205 | + | github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= | |
| 188 | 206 | github.com/darkweak/go-esi v0.0.6 h1:eVHCJfqrZwOHPfRK7JTlSYG9F8lfpX/d4lz/41RQkd8= | |
| 189 | 207 | github.com/darkweak/go-esi v0.0.6/go.mod h1:IJSayeQZDUh5R5ayyDC3wUEBykti12aUa0eUxZZeodk= | |
| 190 | 208 | github.com/darkweak/souin v1.7.7 h1:pIj/cknEsV/+xgq74VOGE1+0yy0dNnt5I6HGRczJlKk= |
| ... | ... | @@ -235,10 +253,18 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r | |
| 235 | 253 | github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= | |
| 236 | 254 | github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c= | |
| 237 | 255 | github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4= | |
| 256 | + | github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= | |
| 257 | + | github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= | |
| 238 | 258 | github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= | |
| 239 | 259 | github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= | |
| 240 | 260 | github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ= | |
| 241 | 261 | github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= | |
| 262 | + | github.com/docker/docker v28.5.1+incompatible h1:Bm8DchhSD2J6PsFzxC35TZo4TLGR2PdW/E69rU45NhM= | |
| 263 | + | github.com/docker/docker v28.5.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= | |
| 264 | + | github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94= | |
| 265 | + | github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE= | |
| 266 | + | github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= | |
| 267 | + | github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= | |
| 242 | 268 | github.com/dolthub/maphash v0.1.0 h1:bsQ7JsF4FkkWyrP3oCnFJgrCUAFbFf3kOl4L/QxPDyQ= | |
| 243 | 269 | github.com/dolthub/maphash v0.1.0/go.mod h1:gkg4Ch4CdCDu5h6PMriVLawB7koZ+5ijb9puGMV50a4= | |
| 244 | 270 | github.com/dsoprea/go-exif v0.0.0-20230826092837-6579e82b732d h1:ygcRCGNKuEiA98k7X35hknEN8RIRUF1jrz7k1rZCvsk= |
| ... | ... | @@ -268,6 +294,8 @@ github.com/dsoprea/go-utility/v2 v2.0.0-20200717064901-2fccff4aa15e/go.mod h1:uA | |
| 268 | 294 | github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= | |
| 269 | 295 | github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= | |
| 270 | 296 | github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= | |
| 297 | + | github.com/ebitengine/purego v0.8.4 h1:CF7LEKg5FFOsASUj0+QwaXf8Ht6TlFxg09+S9wz0omw= | |
| 298 | + | github.com/ebitengine/purego v0.8.4/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ= | |
| 271 | 299 | github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6 h1:oP4q0fw+fOSWn3DfFi4EXdT+B+gTtzx8GC9xsc26Znk= | |
| 272 | 300 | github.com/emersion/go-sasl v0.0.0-20241020182733-b788ff22d5a6/go.mod h1:iL2twTeMvZnrg54ZoPDNfJaJaqy0xIQFuBdrLsmspwQ= | |
| 273 | 301 | github.com/emersion/go-smtp v0.23.0 h1:ZiriTOTK7sKep7jbWqgB5kPsiBp5wnE5auEMnwRMnGc= |
| ... | ... | @@ -317,6 +345,7 @@ github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vb | |
| 317 | 345 | github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= | |
| 318 | 346 | github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= | |
| 319 | 347 | github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= | |
| 348 | + | github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= | |
| 320 | 349 | github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= | |
| 321 | 350 | github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= | |
| 322 | 351 | github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= |
| ... | ... | @@ -437,6 +466,9 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN | |
| 437 | 466 | github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= | |
| 438 | 467 | github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= | |
| 439 | 468 | github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= | |
| 469 | + | github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= | |
| 470 | + | github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 h1:VNqngBF40hVlDloBruUehVYC3ArSgIyScOAyMRqBxRg= | |
| 471 | + | github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1/go.mod h1:RBRO7fro65R6tjKzYgLAFo0t1QEXY1Dp+i/bvpRiqiQ= | |
| 440 | 472 | github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= | |
| 441 | 473 | github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= | |
| 442 | 474 | github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= |
| ... | ... | @@ -536,6 +568,8 @@ github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr32 | |
| 536 | 568 | github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= | |
| 537 | 569 | github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= | |
| 538 | 570 | github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= | |
| 571 | + | github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE= | |
| 572 | + | github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= | |
| 539 | 573 | github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= | |
| 540 | 574 | github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= | |
| 541 | 575 | github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= |
| ... | ... | @@ -561,6 +595,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zk | |
| 561 | 595 | github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= | |
| 562 | 596 | github.com/maypok86/otter v1.2.4 h1:HhW1Pq6VdJkmWwcZZq19BlEQkHtI8xgsQzBVXJU0nfc= | |
| 563 | 597 | github.com/maypok86/otter v1.2.4/go.mod h1:mKLfoI7v1HOmQMwFgX4QkRk23mX6ge3RDvjdHOWG4R4= | |
| 598 | + | github.com/mdelapenya/tlscert v0.2.0 h1:7H81W6Z/4weDvZBNOfQte5GpIMo0lGYEeWbkGp5LJHI= | |
| 599 | + | github.com/mdelapenya/tlscert v0.2.0/go.mod h1:O4njj3ELLnJjGdkN7M/vIVCpZ+Cf0L6muqOG4tLSl8o= | |
| 564 | 600 | github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI= | |
| 565 | 601 | github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= | |
| 566 | 602 | github.com/mholt/acmez/v3 v3.1.2 h1:auob8J/0FhmdClQicvJvuDavgd5ezwLBfKuYmynhYzc= |
| ... | ... | @@ -596,6 +632,22 @@ github.com/mmcdole/goxpp v1.1.1 h1:RGIX+D6iQRIunGHrKqnA2+700XMCnNv0bAOOv5MUhx8= | |
| 596 | 632 | github.com/mmcdole/goxpp v1.1.1/go.mod h1:v+25+lT2ViuQ7mVxcncQ8ch1URund48oH+jhjiwEgS8= | |
| 597 | 633 | github.com/mmcloughlin/md4 v0.1.2 h1:kGYl+iNbxhyz4u76ka9a+0TXP9KWt/LmnM0QhZwhcBo= | |
| 598 | 634 | github.com/mmcloughlin/md4 v0.1.2/go.mod h1:AAxFX59fddW0IguqNzWlf1lazh1+rXeIt/Bj49cqDTQ= | |
| 635 | + | github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= | |
| 636 | + | github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= | |
| 637 | + | github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ= | |
| 638 | + | github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo= | |
| 639 | + | github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= | |
| 640 | + | github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc= | |
| 641 | + | github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw= | |
| 642 | + | github.com/moby/sys/atomicwriter v0.1.0/go.mod h1:Ul8oqv2ZMNHOceF643P6FKPXeCmYtlQMvpizfsSoaWs= | |
| 643 | + | github.com/moby/sys/sequential v0.6.0 h1:qrx7XFUd/5DxtqcoH1h438hF5TmOvzC/lspjy7zgvCU= | |
| 644 | + | github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiTWd+lL+7b/Ko= | |
| 645 | + | github.com/moby/sys/user v0.4.0 h1:jhcMKit7SA80hivmFJcbB1vqmw//wU61Zdui2eQXuMs= | |
| 646 | + | github.com/moby/sys/user v0.4.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs= | |
| 647 | + | github.com/moby/sys/userns v0.1.0 h1:tVLXkFOxVu9A64/yh59slHVv9ahO9UIev4JZusOLG/g= | |
| 648 | + | github.com/moby/sys/userns v0.1.0/go.mod h1:IHUYgu/kao6N8YZlp9Cf444ySSvCmDlmzUcYfDHOl28= | |
| 649 | + | github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= | |
| 650 | + | github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= | |
| 599 | 651 | github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= | |
| 600 | 652 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= | |
| 601 | 653 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= |
| ... | ... | @@ -603,6 +655,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN | |
| 603 | 655 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= | |
| 604 | 656 | github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= | |
| 605 | 657 | github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= | |
| 658 | + | github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= | |
| 659 | + | github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= | |
| 606 | 660 | github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= | |
| 607 | 661 | github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= | |
| 608 | 662 | github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= |
| ... | ... | @@ -642,6 +696,10 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl | |
| 642 | 696 | github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= | |
| 643 | 697 | github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8= | |
| 644 | 698 | github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY= | |
| 699 | + | github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= | |
| 700 | + | github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= | |
| 701 | + | github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= | |
| 702 | + | github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= | |
| 645 | 703 | github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= | |
| 646 | 704 | github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= | |
| 647 | 705 | github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= |
| ... | ... | @@ -746,6 +804,8 @@ github.com/secure-io/sio-go v0.3.1/go.mod h1:+xbkjDzPjwh4Axd07pRKSNriS9SCiYksWnZ | |
| 746 | 804 | github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= | |
| 747 | 805 | github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= | |
| 748 | 806 | github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk= | |
| 807 | + | github.com/shirou/gopsutil/v4 v4.25.6 h1:kLysI2JsKorfaFPcYmcJqbzROzsBWEOAtw6A7dIfqXs= | |
| 808 | + | github.com/shirou/gopsutil/v4 v4.25.6/go.mod h1:PfybzyydfZcN+JMMjkF6Zb8Mq1A/VcogFFg7hj50W9c= | |
| 749 | 809 | github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= | |
| 750 | 810 | github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= | |
| 751 | 811 | github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= |
| ... | ... | @@ -829,6 +889,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ | |
| 829 | 889 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | |
| 830 | 890 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= | |
| 831 | 891 | github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= | |
| 892 | + | github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= | |
| 832 | 893 | github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= | |
| 833 | 894 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= | |
| 834 | 895 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= |
| ... | ... | @@ -841,11 +902,15 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO | |
| 841 | 902 | github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= | |
| 842 | 903 | github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | |
| 843 | 904 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | |
| 844 | - | github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= | |
| 845 | - | github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= | |
| 905 | + | github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= | |
| 906 | + | github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= | |
| 846 | 907 | github.com/tailscale/tscert v0.0.0-20240608151842-d3f834017e53 h1:uxMgm0C+EjytfAqyfBG55ZONKQ7mvd7x4YYCWsf8QHQ= | |
| 847 | 908 | github.com/tailscale/tscert v0.0.0-20240608151842-d3f834017e53/go.mod h1:kNGUQ3VESx3VZwRwA9MSCUegIl6+saPL8Noq82ozCaU= | |
| 848 | 909 | github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= | |
| 910 | + | github.com/testcontainers/testcontainers-go v0.40.0 h1:pSdJYLOVgLE8YdUY2FHQ1Fxu+aMnb6JfVz1mxk7OeMU= | |
| 911 | + | github.com/testcontainers/testcontainers-go v0.40.0/go.mod h1:FSXV5KQtX2HAMlm7U3APNyLkkap35zNLxukw9oBi/MY= | |
| 912 | + | github.com/testcontainers/testcontainers-go/modules/postgres v0.40.0 h1:s2bIayFXlbDFexo96y+htn7FzuhpXLYJNnIuglNKqOk= | |
| 913 | + | github.com/testcontainers/testcontainers-go/modules/postgres v0.40.0/go.mod h1:h+u/2KoREGTnTl9UwrQ/g+XhasAT8E6dClclAADeXoQ= | |
| 849 | 914 | github.com/tidwall/btree v1.1.0/go.mod h1:TzIRzen6yHbibdSfK6t8QimqbUnoxUSrZfeW7Uob0q4= | |
| 850 | 915 | github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= | |
| 851 | 916 | github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= |
| ... | ... | @@ -928,16 +993,22 @@ go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.5 | |
| 928 | 993 | go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0/go.mod h1:ijPqXp5P6IRRByFVVg9DY8P5HkxkHE5ARIa+86aXPf4= | |
| 929 | 994 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 h1:CV7UdSGJt/Ao6Gp4CXckLxVRRsRgDHoI8XjbL3PDl8s= | |
| 930 | 995 | go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0/go.mod h1:FRmFuRJfag1IZ2dPkHnEoSFVgTVPUd2qf5Vi69hLb8I= | |
| 931 | - | go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= | |
| 932 | - | go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= | |
| 933 | - | go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= | |
| 934 | - | go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= | |
| 996 | + | go.opentelemetry.io/otel v1.35.0 h1:xKWKPxrxB6OtMCbmMY021CqC45J+3Onta9MqjhnusiQ= | |
| 997 | + | go.opentelemetry.io/otel v1.35.0/go.mod h1:UEqy8Zp11hpkUrL73gSlELM0DupHoiq72dR+Zqel/+Y= | |
| 998 | + | go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0 h1:OeNbIYk/2C15ckl7glBlOBp5+WlYsOElzTNmiPW/x60= | |
| 999 | + | go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.34.0/go.mod h1:7Bept48yIeqxP2OZ9/AqIpYS94h2or0aB4FypJTc8ZM= | |
| 1000 | + | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0 h1:BEj3SPM81McUZHYjRS5pEgNgnmzGJ5tRpU5krWnV8Bs= | |
| 1001 | + | go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0/go.mod h1:9cKLGBDzI/F3NoHLQGm4ZrYdIHsvGt6ej6hUowxY0J4= | |
| 1002 | + | go.opentelemetry.io/otel/metric v1.35.0 h1:0znxYu2SNyuMSQT4Y9WDWej0VpcsxkuklLa4/siN90M= | |
| 1003 | + | go.opentelemetry.io/otel/metric v1.35.0/go.mod h1:nKVFgxBZ2fReX6IlyW28MgZojkoAkJGaE8CpgeAU3oE= | |
| 935 | 1004 | go.opentelemetry.io/otel/sdk v1.34.0 h1:95zS4k/2GOy069d321O8jWgYsW3MzVV+KuSPKp7Wr1A= | |
| 936 | 1005 | go.opentelemetry.io/otel/sdk v1.34.0/go.mod h1:0e/pNiaMAqaykJGKbi+tSjWfNNHMTxoC9qANsCzbyxU= | |
| 937 | 1006 | go.opentelemetry.io/otel/sdk/metric v1.34.0 h1:5CeK9ujjbFVL5c1PhLuStg1wxA7vQv7ce1EK0Gyvahk= | |
| 938 | 1007 | go.opentelemetry.io/otel/sdk/metric v1.34.0/go.mod h1:jQ/r8Ze28zRKoNRdkjCZxfs6YvBTG1+YIqyFVFYec5w= | |
| 939 | - | go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= | |
| 940 | - | go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= | |
| 1008 | + | go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt/xgMs= | |
| 1009 | + | go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= | |
| 1010 | + | go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4= | |
| 1011 | + | go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4= | |
| 941 | 1012 | go.step.sm/crypto v0.60.0 h1:UgSw8DFG5xUOGB3GUID17UA32G4j1iNQ4qoMhBmsVFw= | |
| 942 | 1013 | go.step.sm/crypto v0.60.0/go.mod h1:Ep83Lv818L4gV0vhFTdPWRKnL6/5fRMpi8SaoP5ArSw= | |
| 943 | 1014 | go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= |
| ... | ... | @@ -970,8 +1041,8 @@ golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v | |
| 970 | 1041 | golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= | |
| 971 | 1042 | golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= | |
| 972 | 1043 | golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= | |
| 973 | - | golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8= | |
| 974 | - | golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw= | |
| 1044 | + | golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04= | |
| 1045 | + | golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0= | |
| 975 | 1046 | golang.org/x/crypto/x509roots/fallback v0.0.0-20250317152234-d0a798f77473 h1:XxwA7BHJuoBTkv1tIM7d/8rDnl9i9M0M5anwcJWZtbA= | |
| 976 | 1047 | golang.org/x/crypto/x509roots/fallback v0.0.0-20250317152234-d0a798f77473/go.mod h1:lxN5T34bK4Z/i6cMaU7frUU57VkDXFD4Kamfl/cp9oU= | |
| 977 | 1048 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= |
| ... | ... | @@ -992,8 +1063,8 @@ golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= | |
| 992 | 1063 | golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= | |
| 993 | 1064 | golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= | |
| 994 | 1065 | golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= | |
| 995 | - | golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= | |
| 996 | - | golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= | |
| 1066 | + | golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U= | |
| 1067 | + | golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI= | |
| 997 | 1068 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | |
| 998 | 1069 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | |
| 999 | 1070 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
| ... | ... | @@ -1030,8 +1101,8 @@ golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= | |
| 1030 | 1101 | golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= | |
| 1031 | 1102 | golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= | |
| 1032 | 1103 | golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= | |
| 1033 | - | golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= | |
| 1034 | - | golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= | |
| 1104 | + | golang.org/x/net v0.45.0 h1:RLBg5JKixCy82FtLJpeNlVM0nrSqpCRYzVU1n8kj0tM= | |
| 1105 | + | golang.org/x/net v0.45.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= | |
| 1035 | 1106 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | |
| 1036 | 1107 | golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= | |
| 1037 | 1108 | golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= |
| ... | ... | @@ -1056,8 +1127,8 @@ golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | |
| 1056 | 1127 | golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | |
| 1057 | 1128 | golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | |
| 1058 | 1129 | golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | |
| 1059 | - | golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ= | |
| 1060 | - | golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= | |
| 1130 | + | golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug= | |
| 1131 | + | golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= | |
| 1061 | 1132 | golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | |
| 1062 | 1133 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | |
| 1063 | 1134 | golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
| ... | ... | @@ -1097,10 +1168,12 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w | |
| 1097 | 1168 | golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1098 | 1169 | golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1099 | 1170 | golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1171 | + | golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1100 | 1172 | golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1101 | 1173 | golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1102 | 1174 | golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1103 | 1175 | golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1176 | + | golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1104 | 1177 | golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1105 | 1178 | golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | |
| 1106 | 1179 | golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
| ... | ... | @@ -1115,8 +1188,8 @@ golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | |
| 1115 | 1188 | golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | |
| 1116 | 1189 | golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | |
| 1117 | 1190 | golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= | |
| 1118 | - | golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw= | |
| 1119 | - | golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= | |
| 1191 | + | golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ= | |
| 1192 | + | golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= | |
| 1120 | 1193 | golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= | |
| 1121 | 1194 | golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | |
| 1122 | 1195 | golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= |
| ... | ... | @@ -1128,8 +1201,8 @@ golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= | |
| 1128 | 1201 | golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= | |
| 1129 | 1202 | golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= | |
| 1130 | 1203 | golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= | |
| 1131 | - | golang.org/x/term v0.32.0 h1:DR4lr0TjUs3epypdhTOkMmuF5CDFJ/8pOnbzMZPQ7bg= | |
| 1132 | - | golang.org/x/term v0.32.0/go.mod h1:uZG1FhGx848Sqfsq4/DlJr3xGGsYMu/L5GW4abiaEPQ= | |
| 1204 | + | golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q= | |
| 1205 | + | golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss= | |
| 1133 | 1206 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | |
| 1134 | 1207 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | |
| 1135 | 1208 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= |
| ... | ... | @@ -1144,8 +1217,8 @@ golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= | |
| 1144 | 1217 | golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= | |
| 1145 | 1218 | golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= | |
| 1146 | 1219 | golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= | |
| 1147 | - | golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4= | |
| 1148 | - | golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA= | |
| 1220 | + | golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k= | |
| 1221 | + | golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM= | |
| 1149 | 1222 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | |
| 1150 | 1223 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= | |
| 1151 | 1224 | golang.org/x/time v0.11.0 h1:/bpjEDfN9tkoN/ryeYHnv5hcMlc8ncjMcM4XBk5NWV0= |
| ... | ... | @@ -1167,8 +1240,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc | |
| 1167 | 1240 | golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= | |
| 1168 | 1241 | golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= | |
| 1169 | 1242 | golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= | |
| 1170 | - | golang.org/x/tools v0.31.0 h1:0EedkvKDbh+qistFTd0Bcwe/YLh4vHwWEkiI0toFIBU= | |
| 1171 | - | golang.org/x/tools v0.31.0/go.mod h1:naFTU+Cev749tSJRXJlna0T3WxKvb1kWEx15xA4SdmQ= | |
| 1243 | + | golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE= | |
| 1244 | + | golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w= | |
| 1172 | 1245 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |
| 1173 | 1246 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | |
| 1174 | 1247 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
| ... | ... | @@ -1243,6 +1316,8 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= | |
| 1243 | 1316 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | |
| 1244 | 1317 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | |
| 1245 | 1318 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= | |
| 1319 | + | gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= | |
| 1320 | + | gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= | |
| 1246 | 1321 | grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= | |
| 1247 | 1322 | honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= | |
| 1248 | 1323 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= |
+1472
-0
pkg/db/postgres/storage_test.go
#
| ... | ... | @@ -0,0 +1,1472 @@ | |
| 1 | + | package postgres | |
| 2 | + | ||
| 3 | + | import ( | |
| 4 | + | "context" | |
| 5 | + | "database/sql" | |
| 6 | + | "fmt" | |
| 7 | + | "log/slog" | |
| 8 | + | "os" | |
| 9 | + | "os/exec" | |
| 10 | + | "path/filepath" | |
| 11 | + | "runtime" | |
| 12 | + | "sort" | |
| 13 | + | "testing" | |
| 14 | + | "time" | |
| 15 | + | ||
| 16 | + | _ "github.com/lib/pq" | |
| 17 | + | "github.com/picosh/pico/pkg/db" | |
| 18 | + | "github.com/testcontainers/testcontainers-go" | |
| 19 | + | "github.com/testcontainers/testcontainers-go/modules/postgres" | |
| 20 | + | "github.com/testcontainers/testcontainers-go/wait" | |
| 21 | + | ) | |
| 22 | + | ||
| 23 | + | var testDB *PsqlDB | |
| 24 | + | var testLogger *slog.Logger | |
| 25 | + | var skipTests bool | |
| 26 | + | ||
| 27 | + | func setupContainerRuntime() bool { | |
| 28 | + | // Check if DATABASE_URL is set for external postgres (CI/CD or manual testing) | |
| 29 | + | if os.Getenv("TEST_DATABASE_URL") != "" { | |
| 30 | + | return true | |
| 31 | + | } | |
| 32 | + | ||
| 33 | + | // Try podman first | |
| 34 | + | if cmd := exec.Command("podman", "info"); cmd.Run() == nil { | |
| 35 | + | // For podman, we need to ensure the socket is running | |
| 36 | + | // User should run: systemctl --user start podman.socket | |
| 37 | + | os.Setenv("TESTCONTAINERS_RYUK_DISABLED", "true") | |
| 38 | + | ||
| 39 | + | // Check if socket exists and is accessible | |
| 40 | + | xdgRuntime := os.Getenv("XDG_RUNTIME_DIR") | |
| 41 | + | if xdgRuntime != "" { | |
| 42 | + | socketPath := xdgRuntime + "/podman/podman.sock" | |
| 43 | + | if _, err := os.Stat(socketPath); err == nil { | |
| 44 | + | os.Setenv("DOCKER_HOST", "unix://"+socketPath) | |
| 45 | + | return true | |
| 46 | + | } | |
| 47 | + | } | |
| 48 | + | // Socket not available, need to start it | |
| 49 | + | fmt.Println("Podman detected but socket not running. Run: systemctl --user start podman.socket") | |
| 50 | + | return false | |
| 51 | + | } | |
| 52 | + | ||
| 53 | + | // Try docker | |
| 54 | + | if cmd := exec.Command("docker", "info"); cmd.Run() == nil { | |
| 55 | + | return true | |
| 56 | + | } | |
| 57 | + | ||
| 58 | + | return false | |
| 59 | + | } | |
| 60 | + | ||
| 61 | + | func TestMain(m *testing.M) { | |
| 62 | + | ctx := context.Background() | |
| 63 | + | testLogger = slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelError})) | |
| 64 | + | ||
| 65 | + | // Check for external database URL first (for CI/CD or manual testing) | |
| 66 | + | if dbURL := os.Getenv("TEST_DATABASE_URL"); dbURL != "" { | |
| 67 | + | testDB = NewDB(dbURL, testLogger) | |
| 68 | + | if err := setupTestSchema(testDB.Db); err != nil { | |
| 69 | + | panic(fmt.Sprintf("failed to setup schema: %s", err)) | |
| 70 | + | } | |
| 71 | + | code := m.Run() | |
| 72 | + | _ = testDB.Close() | |
| 73 | + | os.Exit(code) | |
| 74 | + | } | |
| 75 | + | ||
| 76 | + | if !setupContainerRuntime() { | |
| 77 | + | fmt.Println("Container runtime not available, skipping integration tests") | |
| 78 | + | fmt.Println("To run tests, either:") | |
| 79 | + | fmt.Println(" - Set TEST_DATABASE_URL to a postgres connection string") | |
| 80 | + | fmt.Println(" - Start podman socket: systemctl --user start podman.socket") | |
| 81 | + | fmt.Println(" - Start docker daemon") | |
| 82 | + | skipTests = true | |
| 83 | + | os.Exit(0) | |
| 84 | + | } | |
| 85 | + | ||
| 86 | + | pgContainer, err := postgres.Run(ctx, | |
| 87 | + | "postgres:14", | |
| 88 | + | postgres.WithDatabase("pico_test"), | |
| 89 | + | postgres.WithUsername("postgres"), | |
| 90 | + | postgres.WithPassword("postgres"), | |
| 91 | + | testcontainers.WithWaitStrategy( | |
| 92 | + | wait.ForLog("database system is ready to accept connections"). | |
| 93 | + | WithOccurrence(2). | |
| 94 | + | WithStartupTimeout(30*time.Second)), | |
| 95 | + | ) | |
| 96 | + | if err != nil { | |
| 97 | + | fmt.Printf("Failed to start postgres container (Docker may not be running): %s\n", err) | |
| 98 | + | skipTests = true | |
| 99 | + | os.Exit(0) | |
| 100 | + | } | |
| 101 | + | ||
| 102 | + | connStr, err := pgContainer.ConnectionString(ctx, "sslmode=disable") | |
| 103 | + | if err != nil { | |
| 104 | + | panic(fmt.Sprintf("failed to get connection string: %s", err)) | |
| 105 | + | } | |
| 106 | + | ||
| 107 | + | testDB = NewDB(connStr, testLogger) | |
| 108 | + | ||
| 109 | + | if err := setupTestSchema(testDB.Db); err != nil { | |
| 110 | + | panic(fmt.Sprintf("failed to setup schema: %s", err)) | |
| 111 | + | } | |
| 112 | + | ||
| 113 | + | code := m.Run() | |
| 114 | + | ||
| 115 | + | _ = testDB.Close() | |
| 116 | + | _ = pgContainer.Terminate(ctx) | |
| 117 | + | ||
| 118 | + | os.Exit(code) | |
| 119 | + | } | |
| 120 | + | ||
| 121 | + | func getProjectRoot() string { | |
| 122 | + | _, filename, _, ok := runtime.Caller(0) | |
| 123 | + | if !ok { | |
| 124 | + | panic("failed to get current file path") | |
| 125 | + | } | |
| 126 | + | // storage_test.go is in pkg/db/postgres/, so go up 4 levels to get project root | |
| 127 | + | return filepath.Join(filepath.Dir(filename), "..", "..", "..") | |
| 128 | + | } | |
| 129 | + | ||
| 130 | + | func setupTestSchema(db *sql.DB) error { | |
| 131 | + | projectRoot := getProjectRoot() | |
| 132 | + | migrationsDir := filepath.Join(projectRoot, "sql", "migrations") | |
| 133 | + | ||
| 134 | + | // Read all migration files | |
| 135 | + | entries, err := os.ReadDir(migrationsDir) | |
| 136 | + | if err != nil { | |
| 137 | + | return fmt.Errorf("failed to read migrations directory: %w", err) | |
| 138 | + | } | |
| 139 | + | ||
| 140 | + | // Sort by filename (they're date-prefixed, so alphabetical order is correct) | |
| 141 | + | var migrationFiles []string | |
| 142 | + | for _, entry := range entries { | |
| 143 | + | if !entry.IsDir() && filepath.Ext(entry.Name()) == ".sql" { | |
| 144 | + | migrationFiles = append(migrationFiles, entry.Name()) | |
| 145 | + | } | |
| 146 | + | } | |
| 147 | + | sort.Strings(migrationFiles) | |
| 148 | + | ||
| 149 | + | // Execute each migration in order | |
| 150 | + | for _, filename := range migrationFiles { | |
| 151 | + | migrationPath := filepath.Join(migrationsDir, filename) | |
| 152 | + | content, err := os.ReadFile(migrationPath) | |
| 153 | + | if err != nil { | |
| 154 | + | return fmt.Errorf("failed to read migration %s: %w", filename, err) | |
| 155 | + | } | |
| 156 | + | ||
| 157 | + | _, err = db.Exec(string(content)) | |
| 158 | + | if err != nil { | |
| 159 | + | return fmt.Errorf("failed to execute migration %s: %w", filename, err) | |
| 160 | + | } | |
| 161 | + | } | |
| 162 | + | ||
| 163 | + | return nil | |
| 164 | + | } | |
| 165 | + | ||
| 166 | + | func cleanupTestData(t *testing.T) { | |
| 167 | + | t.Helper() | |
| 168 | + | tables := []string{ | |
| 169 | + | "access_logs", "tuns_event_logs", "analytics_visits", | |
| 170 | + | "feed_items", "post_aliases", "post_tags", "posts", | |
| 171 | + | "projects", "feature_flags", "payment_history", "tokens", | |
| 172 | + | "public_keys", "app_users", | |
| 173 | + | } | |
| 174 | + | for _, table := range tables { | |
| 175 | + | _, err := testDB.Db.Exec(fmt.Sprintf("DELETE FROM %s", table)) | |
| 176 | + | if err != nil { | |
| 177 | + | t.Fatalf("failed to clean up %s: %v", table, err) | |
| 178 | + | } | |
| 179 | + | } | |
| 180 | + | } | |
| 181 | + | ||
| 182 | + | func mustInsertPost(t *testing.T, post *db.Post) *db.Post { | |
| 183 | + | t.Helper() | |
| 184 | + | now := time.Now() | |
| 185 | + | if post.UpdatedAt == nil { | |
| 186 | + | post.UpdatedAt = &now | |
| 187 | + | } | |
| 188 | + | if post.PublishAt == nil { | |
| 189 | + | post.PublishAt = &now | |
| 190 | + | } | |
| 191 | + | created, err := testDB.InsertPost(post) | |
| 192 | + | if err != nil { | |
| 193 | + | t.Fatalf("InsertPost failed: %v", err) | |
| 194 | + | } | |
| 195 | + | return created | |
| 196 | + | } | |
| 197 | + | ||
| 198 | + | // ============ User Management Tests ============ | |
| 199 | + | ||
| 200 | + | func TestRegisterUser_Success(t *testing.T) { | |
| 201 | + | cleanupTestData(t) | |
| 202 | + | ||
| 203 | + | user, err := testDB.RegisterUser("testuser", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI testkey", "test comment") | |
| 204 | + | if err != nil { | |
| 205 | + | t.Fatalf("RegisterUser failed: %v", err) | |
| 206 | + | } | |
| 207 | + | if user == nil { | |
| 208 | + | t.Fatal("expected user, got nil") | |
| 209 | + | } | |
| 210 | + | if user.Name != "testuser" { | |
| 211 | + | t.Errorf("expected name 'testuser', got '%s'", user.Name) | |
| 212 | + | } | |
| 213 | + | if user.PublicKey == nil { | |
| 214 | + | t.Fatal("expected public key, got nil") | |
| 215 | + | } | |
| 216 | + | } | |
| 217 | + | ||
| 218 | + | func TestRegisterUser_DuplicateName(t *testing.T) { | |
| 219 | + | cleanupTestData(t) | |
| 220 | + | ||
| 221 | + | _, err := testDB.RegisterUser("duplicateuser", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI key1", "comment1") | |
| 222 | + | if err != nil { | |
| 223 | + | t.Fatalf("first RegisterUser failed: %v", err) | |
| 224 | + | } | |
| 225 | + | ||
| 226 | + | _, err = testDB.RegisterUser("duplicateuser", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI key2", "comment2") | |
| 227 | + | if err == nil { | |
| 228 | + | t.Error("expected error for duplicate name, got nil") | |
| 229 | + | } | |
| 230 | + | } | |
| 231 | + | ||
| 232 | + | func TestRegisterUser_DeniedName(t *testing.T) { | |
| 233 | + | cleanupTestData(t) | |
| 234 | + | ||
| 235 | + | _, err := testDB.RegisterUser("admin", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI adminkey", "comment") | |
| 236 | + | if err == nil { | |
| 237 | + | t.Error("expected error for denied name 'admin', got nil") | |
| 238 | + | } | |
| 239 | + | } | |
| 240 | + | ||
| 241 | + | func TestRegisterUser_InvalidName(t *testing.T) { | |
| 242 | + | cleanupTestData(t) | |
| 243 | + | ||
| 244 | + | _, err := testDB.RegisterUser("user@invalid", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI invalidkey", "comment") | |
| 245 | + | if err == nil { | |
| 246 | + | t.Error("expected error for invalid name, got nil") | |
| 247 | + | } | |
| 248 | + | } | |
| 249 | + | ||
| 250 | + | func TestFindUser(t *testing.T) { | |
| 251 | + | cleanupTestData(t) | |
| 252 | + | ||
| 253 | + | created, err := testDB.RegisterUser("findme", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI findmekey", "comment") | |
| 254 | + | if err != nil { | |
| 255 | + | t.Fatalf("RegisterUser failed: %v", err) | |
| 256 | + | } | |
| 257 | + | ||
| 258 | + | found, err := testDB.FindUser(created.ID) | |
| 259 | + | if err != nil { | |
| 260 | + | t.Fatalf("FindUser failed: %v", err) | |
| 261 | + | } | |
| 262 | + | if found.Name != "findme" { | |
| 263 | + | t.Errorf("expected name 'findme', got '%s'", found.Name) | |
| 264 | + | } | |
| 265 | + | } | |
| 266 | + | ||
| 267 | + | func TestFindUserByName(t *testing.T) { | |
| 268 | + | cleanupTestData(t) | |
| 269 | + | ||
| 270 | + | _, err := testDB.RegisterUser("nameduser", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI namedkey", "comment") | |
| 271 | + | if err != nil { | |
| 272 | + | t.Fatalf("RegisterUser failed: %v", err) | |
| 273 | + | } | |
| 274 | + | ||
| 275 | + | found, err := testDB.FindUserByName("nameduser") | |
| 276 | + | if err != nil { | |
| 277 | + | t.Fatalf("FindUserByName failed: %v", err) | |
| 278 | + | } | |
| 279 | + | if found.Name != "nameduser" { | |
| 280 | + | t.Errorf("expected name 'nameduser', got '%s'", found.Name) | |
| 281 | + | } | |
| 282 | + | } | |
| 283 | + | ||
| 284 | + | func TestFindUserByPubkey(t *testing.T) { | |
| 285 | + | cleanupTestData(t) | |
| 286 | + | ||
| 287 | + | pubkey := "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI pubkeyuser" | |
| 288 | + | _, err := testDB.RegisterUser("pubkeyuser", pubkey, "comment") | |
| 289 | + | if err != nil { | |
| 290 | + | t.Fatalf("RegisterUser failed: %v", err) | |
| 291 | + | } | |
| 292 | + | ||
| 293 | + | found, err := testDB.FindUserByPubkey(pubkey) | |
| 294 | + | if err != nil { | |
| 295 | + | t.Fatalf("FindUserByPubkey failed: %v", err) | |
| 296 | + | } | |
| 297 | + | if found.Name != "pubkeyuser" { | |
| 298 | + | t.Errorf("expected name 'pubkeyuser', got '%s'", found.Name) | |
| 299 | + | } | |
| 300 | + | } | |
| 301 | + | ||
| 302 | + | func TestFindUserForKey(t *testing.T) { | |
| 303 | + | cleanupTestData(t) | |
| 304 | + | ||
| 305 | + | pubkey := "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI forkeyfind" | |
| 306 | + | _, err := testDB.RegisterUser("forkeyfind", pubkey, "comment") | |
| 307 | + | if err != nil { | |
| 308 | + | t.Fatalf("RegisterUser failed: %v", err) | |
| 309 | + | } | |
| 310 | + | ||
| 311 | + | found, err := testDB.FindUserForKey("forkeyfind", pubkey) | |
| 312 | + | if err != nil { | |
| 313 | + | t.Fatalf("FindUserForKey failed: %v", err) | |
| 314 | + | } | |
| 315 | + | if found.Name != "forkeyfind" { | |
| 316 | + | t.Errorf("expected name 'forkeyfind', got '%s'", found.Name) | |
| 317 | + | } | |
| 318 | + | } | |
| 319 | + | ||
| 320 | + | func TestFindUsers(t *testing.T) { | |
| 321 | + | cleanupTestData(t) | |
| 322 | + | ||
| 323 | + | _, _ = testDB.RegisterUser("user1", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI user1key", "comment") | |
| 324 | + | _, _ = testDB.RegisterUser("user2", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI user2key", "comment") | |
| 325 | + | ||
| 326 | + | users, err := testDB.FindUsers() | |
| 327 | + | if err != nil { | |
| 328 | + | t.Fatalf("FindUsers failed: %v", err) | |
| 329 | + | } | |
| 330 | + | if len(users) != 2 { | |
| 331 | + | t.Errorf("expected 2 users, got %d", len(users)) | |
| 332 | + | } | |
| 333 | + | } | |
| 334 | + | ||
| 335 | + | // ============ Public Key Management Tests ============ | |
| 336 | + | ||
| 337 | + | func TestInsertPublicKey_Success(t *testing.T) { | |
| 338 | + | cleanupTestData(t) | |
| 339 | + | ||
| 340 | + | user, err := testDB.RegisterUser("keyowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI keyowner1", "comment") | |
| 341 | + | if err != nil { | |
| 342 | + | t.Fatalf("RegisterUser failed: %v", err) | |
| 343 | + | } | |
| 344 | + | ||
| 345 | + | err = testDB.InsertPublicKey(user.ID, "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI secondkey", "second key", nil) | |
| 346 | + | if err != nil { | |
| 347 | + | t.Fatalf("InsertPublicKey failed: %v", err) | |
| 348 | + | } | |
| 349 | + | ||
| 350 | + | keys, err := testDB.FindKeysForUser(user) | |
| 351 | + | if err != nil { | |
| 352 | + | t.Fatalf("FindKeysForUser failed: %v", err) | |
| 353 | + | } | |
| 354 | + | if len(keys) != 2 { | |
| 355 | + | t.Errorf("expected 2 keys, got %d", len(keys)) | |
| 356 | + | } | |
| 357 | + | } | |
| 358 | + | ||
| 359 | + | func TestInsertPublicKey_Duplicate(t *testing.T) { | |
| 360 | + | cleanupTestData(t) | |
| 361 | + | ||
| 362 | + | user, _ := testDB.RegisterUser("dupkeyowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI dupkey", "comment") | |
| 363 | + | ||
| 364 | + | err := testDB.InsertPublicKey(user.ID, "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI dupkey", "same key", nil) | |
| 365 | + | if err == nil { | |
| 366 | + | t.Error("expected error for duplicate key, got nil") | |
| 367 | + | } | |
| 368 | + | } | |
| 369 | + | ||
| 370 | + | func TestUpdatePublicKey(t *testing.T) { | |
| 371 | + | cleanupTestData(t) | |
| 372 | + | ||
| 373 | + | user, _ := testDB.RegisterUser("updatekeyowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI updatekeyowner", "original") | |
| 374 | + | ||
| 375 | + | updated, err := testDB.UpdatePublicKey(user.PublicKey.ID, "new-name") | |
| 376 | + | if err != nil { | |
| 377 | + | t.Fatalf("UpdatePublicKey failed: %v", err) | |
| 378 | + | } | |
| 379 | + | if updated.Name != "new-name" { | |
| 380 | + | t.Errorf("expected name 'new-name', got '%s'", updated.Name) | |
| 381 | + | } | |
| 382 | + | } | |
| 383 | + | ||
| 384 | + | func TestFindKeysForUser(t *testing.T) { | |
| 385 | + | cleanupTestData(t) | |
| 386 | + | ||
| 387 | + | user, _ := testDB.RegisterUser("multikeyowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI multikeyowner1", "key1") | |
| 388 | + | _ = testDB.InsertPublicKey(user.ID, "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI multikeyowner2", "key2", nil) | |
| 389 | + | ||
| 390 | + | keys, err := testDB.FindKeysForUser(user) | |
| 391 | + | if err != nil { | |
| 392 | + | t.Fatalf("FindKeysForUser failed: %v", err) | |
| 393 | + | } | |
| 394 | + | if len(keys) != 2 { | |
| 395 | + | t.Errorf("expected 2 keys, got %d", len(keys)) | |
| 396 | + | } | |
| 397 | + | } | |
| 398 | + | ||
| 399 | + | func TestRemoveKeys(t *testing.T) { | |
| 400 | + | cleanupTestData(t) | |
| 401 | + | ||
| 402 | + | user, _ := testDB.RegisterUser("removekeyowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI removekeyowner", "key1") | |
| 403 | + | _ = testDB.InsertPublicKey(user.ID, "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI removekeyowner2", "key2", nil) | |
| 404 | + | ||
| 405 | + | keys, _ := testDB.FindKeysForUser(user) | |
| 406 | + | if len(keys) != 2 { | |
| 407 | + | t.Fatalf("expected 2 keys before removal, got %d", len(keys)) | |
| 408 | + | } | |
| 409 | + | ||
| 410 | + | err := testDB.RemoveKeys([]string{keys[1].ID}) | |
| 411 | + | if err != nil { | |
| 412 | + | t.Fatalf("RemoveKeys failed: %v", err) | |
| 413 | + | } | |
| 414 | + | ||
| 415 | + | keys, _ = testDB.FindKeysForUser(user) | |
| 416 | + | if len(keys) != 1 { | |
| 417 | + | t.Errorf("expected 1 key after removal, got %d", len(keys)) | |
| 418 | + | } | |
| 419 | + | } | |
| 420 | + | ||
| 421 | + | // ============ Token Management Tests ============ | |
| 422 | + | ||
| 423 | + | func TestInsertToken(t *testing.T) { | |
| 424 | + | cleanupTestData(t) | |
| 425 | + | ||
| 426 | + | user, _ := testDB.RegisterUser("tokenowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI tokenowner", "comment") | |
| 427 | + | ||
| 428 | + | token, err := testDB.InsertToken(user.ID, "my-token") | |
| 429 | + | if err != nil { | |
| 430 | + | t.Fatalf("InsertToken failed: %v", err) | |
| 431 | + | } | |
| 432 | + | if token == "" { | |
| 433 | + | t.Error("expected token string, got empty") | |
| 434 | + | } | |
| 435 | + | } | |
| 436 | + | ||
| 437 | + | func TestUpsertToken(t *testing.T) { | |
| 438 | + | cleanupTestData(t) | |
| 439 | + | ||
| 440 | + | user, _ := testDB.RegisterUser("upserttokenowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI upserttokenowner", "comment") | |
| 441 | + | ||
| 442 | + | token1, err := testDB.UpsertToken(user.ID, "upsert-token") | |
| 443 | + | if err != nil { | |
| 444 | + | t.Fatalf("first UpsertToken failed: %v", err) | |
| 445 | + | } | |
| 446 | + | ||
| 447 | + | token2, err := testDB.UpsertToken(user.ID, "upsert-token") | |
| 448 | + | if err != nil { | |
| 449 | + | t.Fatalf("second UpsertToken failed: %v", err) | |
| 450 | + | } | |
| 451 | + | ||
| 452 | + | if token1 != token2 { | |
| 453 | + | t.Errorf("expected same token, got different: %s vs %s", token1, token2) | |
| 454 | + | } | |
| 455 | + | } | |
| 456 | + | ||
| 457 | + | func TestFindTokensForUser(t *testing.T) { | |
| 458 | + | cleanupTestData(t) | |
| 459 | + | ||
| 460 | + | user, _ := testDB.RegisterUser("tokensowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI tokensowner", "comment") | |
| 461 | + | _, _ = testDB.InsertToken(user.ID, "token1") | |
| 462 | + | _, _ = testDB.InsertToken(user.ID, "token2") | |
| 463 | + | ||
| 464 | + | tokens, err := testDB.FindTokensForUser(user.ID) | |
| 465 | + | if err != nil { | |
| 466 | + | t.Fatalf("FindTokensForUser failed: %v", err) | |
| 467 | + | } | |
| 468 | + | if len(tokens) != 2 { | |
| 469 | + | t.Errorf("expected 2 tokens, got %d", len(tokens)) | |
| 470 | + | } | |
| 471 | + | } | |
| 472 | + | ||
| 473 | + | func TestFindUserForToken_Valid(t *testing.T) { | |
| 474 | + | cleanupTestData(t) | |
| 475 | + | ||
| 476 | + | user, _ := testDB.RegisterUser("validtokenowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI validtokenowner", "comment") | |
| 477 | + | token, _ := testDB.InsertToken(user.ID, "valid-token") | |
| 478 | + | ||
| 479 | + | found, err := testDB.FindUserForToken(token) | |
| 480 | + | if err != nil { | |
| 481 | + | t.Fatalf("FindUserForToken failed: %v", err) | |
| 482 | + | } | |
| 483 | + | if found.Name != "validtokenowner" { | |
| 484 | + | t.Errorf("expected name 'validtokenowner', got '%s'", found.Name) | |
| 485 | + | } | |
| 486 | + | } | |
| 487 | + | ||
| 488 | + | func TestFindUserForToken_Expired(t *testing.T) { | |
| 489 | + | cleanupTestData(t) | |
| 490 | + | ||
| 491 | + | user, _ := testDB.RegisterUser("expiredtokenowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI expiredtokenowner", "comment") | |
| 492 | + | token, _ := testDB.InsertToken(user.ID, "expired-token") | |
| 493 | + | ||
| 494 | + | _, err := testDB.Db.Exec("UPDATE tokens SET expires_at = NOW() - INTERVAL '1 day' WHERE token = $1", token) | |
| 495 | + | if err != nil { | |
| 496 | + | t.Fatalf("failed to expire token: %v", err) | |
| 497 | + | } | |
| 498 | + | ||
| 499 | + | _, err = testDB.FindUserForToken(token) | |
| 500 | + | if err == nil { | |
| 501 | + | t.Error("expected error for expired token, got nil") | |
| 502 | + | } | |
| 503 | + | } | |
| 504 | + | ||
| 505 | + | func TestRemoveToken(t *testing.T) { | |
| 506 | + | cleanupTestData(t) | |
| 507 | + | ||
| 508 | + | user, _ := testDB.RegisterUser("removetokenowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI removetokenowner", "comment") | |
| 509 | + | _, _ = testDB.InsertToken(user.ID, "remove-token") | |
| 510 | + | ||
| 511 | + | tokens, _ := testDB.FindTokensForUser(user.ID) | |
| 512 | + | if len(tokens) != 1 { | |
| 513 | + | t.Fatalf("expected 1 token, got %d", len(tokens)) | |
| 514 | + | } | |
| 515 | + | ||
| 516 | + | err := testDB.RemoveToken(tokens[0].ID) | |
| 517 | + | if err != nil { | |
| 518 | + | t.Fatalf("RemoveToken failed: %v", err) | |
| 519 | + | } | |
| 520 | + | ||
| 521 | + | tokens, _ = testDB.FindTokensForUser(user.ID) | |
| 522 | + | if len(tokens) != 0 { | |
| 523 | + | t.Errorf("expected 0 tokens after removal, got %d", len(tokens)) | |
| 524 | + | } | |
| 525 | + | } | |
| 526 | + | ||
| 527 | + | // ============ Post CRUD Tests ============ | |
| 528 | + | ||
| 529 | + | func TestInsertPost(t *testing.T) { | |
| 530 | + | cleanupTestData(t) | |
| 531 | + | ||
| 532 | + | user, _ := testDB.RegisterUser("postowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI postowner", "comment") | |
| 533 | + | ||
| 534 | + | now := time.Now() | |
| 535 | + | post := &db.Post{ | |
| 536 | + | UserID: user.ID, | |
| 537 | + | Filename: "test.md", | |
| 538 | + | Slug: "test-post", | |
| 539 | + | Title: "Test Post", | |
| 540 | + | Text: "Post content", | |
| 541 | + | Description: "A test post", | |
| 542 | + | PublishAt: &now, | |
| 543 | + | UpdatedAt: &now, | |
| 544 | + | Space: "prose", | |
| 545 | + | MimeType: "text/markdown", | |
| 546 | + | } | |
| 547 | + | ||
| 548 | + | created, err := testDB.InsertPost(post) | |
| 549 | + | if err != nil { | |
| 550 | + | t.Fatalf("InsertPost failed: %v", err) | |
| 551 | + | } | |
| 552 | + | if created.ID == "" { | |
| 553 | + | t.Error("expected post ID, got empty") | |
| 554 | + | } | |
| 555 | + | if created.Title != "Test Post" { | |
| 556 | + | t.Errorf("expected title 'Test Post', got '%s'", created.Title) | |
| 557 | + | } | |
| 558 | + | } | |
| 559 | + | ||
| 560 | + | func TestUpdatePost(t *testing.T) { | |
| 561 | + | cleanupTestData(t) | |
| 562 | + | ||
| 563 | + | user, _ := testDB.RegisterUser("updatepostowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI updatepostowner", "comment") | |
| 564 | + | ||
| 565 | + | now := time.Now() | |
| 566 | + | post := mustInsertPost(t, &db.Post{ | |
| 567 | + | UserID: user.ID, | |
| 568 | + | Filename: "update.md", | |
| 569 | + | Slug: "update-post", | |
| 570 | + | Title: "Original Title", | |
| 571 | + | Text: "Original content", | |
| 572 | + | Space: "prose", | |
| 573 | + | }) | |
| 574 | + | ||
| 575 | + | post.Title = "Updated Title" | |
| 576 | + | post.Text = "Updated content" | |
| 577 | + | post.UpdatedAt = &now | |
| 578 | + | ||
| 579 | + | updated, err := testDB.UpdatePost(post) | |
| 580 | + | if err != nil { | |
| 581 | + | t.Fatalf("UpdatePost failed: %v", err) | |
| 582 | + | } | |
| 583 | + | if updated.Title != "Updated Title" { | |
| 584 | + | t.Errorf("expected title 'Updated Title', got '%s'", updated.Title) | |
| 585 | + | } | |
| 586 | + | } | |
| 587 | + | ||
| 588 | + | func TestRemovePosts(t *testing.T) { | |
| 589 | + | cleanupTestData(t) | |
| 590 | + | ||
| 591 | + | user, _ := testDB.RegisterUser("removepostowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI removepostowner", "comment") | |
| 592 | + | ||
| 593 | + | post := mustInsertPost(t, &db.Post{ | |
| 594 | + | UserID: user.ID, | |
| 595 | + | Filename: "remove.md", | |
| 596 | + | Slug: "remove-post", | |
| 597 | + | Title: "To Remove", | |
| 598 | + | Space: "prose", | |
| 599 | + | }) | |
| 600 | + | ||
| 601 | + | err := testDB.RemovePosts([]string{post.ID}) | |
| 602 | + | if err != nil { | |
| 603 | + | t.Fatalf("RemovePosts failed: %v", err) | |
| 604 | + | } | |
| 605 | + | ||
| 606 | + | _, err = testDB.FindPost(post.ID) | |
| 607 | + | if err == nil { | |
| 608 | + | t.Error("expected error finding removed post, got nil") | |
| 609 | + | } | |
| 610 | + | } | |
| 611 | + | ||
| 612 | + | func TestFindPost(t *testing.T) { | |
| 613 | + | cleanupTestData(t) | |
| 614 | + | ||
| 615 | + | user, _ := testDB.RegisterUser("findpostowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI findpostowner", "comment") | |
| 616 | + | ||
| 617 | + | created := mustInsertPost(t, &db.Post{ | |
| 618 | + | UserID: user.ID, | |
| 619 | + | Filename: "find.md", | |
| 620 | + | Slug: "find-post", | |
| 621 | + | Title: "Find Me", | |
| 622 | + | Space: "prose", | |
| 623 | + | }) | |
| 624 | + | ||
| 625 | + | found, err := testDB.FindPost(created.ID) | |
| 626 | + | if err != nil { | |
| 627 | + | t.Fatalf("FindPost failed: %v", err) | |
| 628 | + | } | |
| 629 | + | if found.Title != "Find Me" { | |
| 630 | + | t.Errorf("expected title 'Find Me', got '%s'", found.Title) | |
| 631 | + | } | |
| 632 | + | } | |
| 633 | + | ||
| 634 | + | func TestFindPostWithFilename(t *testing.T) { | |
| 635 | + | cleanupTestData(t) | |
| 636 | + | ||
| 637 | + | user, _ := testDB.RegisterUser("filenamepostowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI filenamepostowner", "comment") | |
| 638 | + | ||
| 639 | + | _ = mustInsertPost(t, &db.Post{ | |
| 640 | + | UserID: user.ID, | |
| 641 | + | Filename: "byfilename.md", | |
| 642 | + | Slug: "byfilename-post", | |
| 643 | + | Title: "By Filename", | |
| 644 | + | Space: "prose", | |
| 645 | + | }) | |
| 646 | + | ||
| 647 | + | found, err := testDB.FindPostWithFilename("byfilename.md", user.ID, "prose") | |
| 648 | + | if err != nil { | |
| 649 | + | t.Fatalf("FindPostWithFilename failed: %v", err) | |
| 650 | + | } | |
| 651 | + | if found.Title != "By Filename" { | |
| 652 | + | t.Errorf("expected title 'By Filename', got '%s'", found.Title) | |
| 653 | + | } | |
| 654 | + | } | |
| 655 | + | ||
| 656 | + | func TestFindPostWithSlug(t *testing.T) { | |
| 657 | + | cleanupTestData(t) | |
| 658 | + | ||
| 659 | + | user, _ := testDB.RegisterUser("slugpostowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI slugpostowner", "comment") | |
| 660 | + | ||
| 661 | + | _ = mustInsertPost(t, &db.Post{ | |
| 662 | + | UserID: user.ID, | |
| 663 | + | Filename: "byslug.md", | |
| 664 | + | Slug: "byslug-post", | |
| 665 | + | Title: "By Slug", | |
| 666 | + | Space: "prose", | |
| 667 | + | }) | |
| 668 | + | ||
| 669 | + | found, err := testDB.FindPostWithSlug("byslug-post", user.ID, "prose") | |
| 670 | + | if err != nil { | |
| 671 | + | t.Fatalf("FindPostWithSlug failed: %v", err) | |
| 672 | + | } | |
| 673 | + | if found.Title != "By Slug" { | |
| 674 | + | t.Errorf("expected title 'By Slug', got '%s'", found.Title) | |
| 675 | + | } | |
| 676 | + | } | |
| 677 | + | ||
| 678 | + | func TestFindPosts(t *testing.T) { | |
| 679 | + | cleanupTestData(t) | |
| 680 | + | ||
| 681 | + | user, _ := testDB.RegisterUser("postsowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI postsowner", "comment") | |
| 682 | + | ||
| 683 | + | _ = mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "post1.md", Slug: "post1", Title: "Post 1", Space: "prose"}) | |
| 684 | + | _ = mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "post2.md", Slug: "post2", Title: "Post 2", Space: "prose"}) | |
| 685 | + | ||
| 686 | + | posts, err := testDB.FindPosts() | |
| 687 | + | if err != nil { | |
| 688 | + | t.Fatalf("FindPosts failed: %v", err) | |
| 689 | + | } | |
| 690 | + | if len(posts) != 2 { | |
| 691 | + | t.Errorf("expected 2 posts, got %d", len(posts)) | |
| 692 | + | } | |
| 693 | + | } | |
| 694 | + | ||
| 695 | + | func TestFindPostsForUser(t *testing.T) { | |
| 696 | + | cleanupTestData(t) | |
| 697 | + | ||
| 698 | + | user, _ := testDB.RegisterUser("userpostsowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI userpostsowner", "comment") | |
| 699 | + | now := time.Now() | |
| 700 | + | ||
| 701 | + | _ = mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "userpost1.md", Slug: "userpost1", Title: "User Post 1", Space: "prose", PublishAt: &now}) | |
| 702 | + | _ = mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "userpost2.md", Slug: "userpost2", Title: "User Post 2", Space: "prose", PublishAt: &now}) | |
| 703 | + | ||
| 704 | + | pager := &db.Pager{Num: 10, Page: 0} | |
| 705 | + | result, err := testDB.FindPostsForUser(pager, user.ID, "prose") | |
| 706 | + | if err != nil { | |
| 707 | + | t.Fatalf("FindPostsForUser failed: %v", err) | |
| 708 | + | } | |
| 709 | + | if len(result.Data) != 2 { | |
| 710 | + | t.Errorf("expected 2 posts, got %d", len(result.Data)) | |
| 711 | + | } | |
| 712 | + | } | |
| 713 | + | ||
| 714 | + | func TestFindAllPostsForUser(t *testing.T) { | |
| 715 | + | cleanupTestData(t) | |
| 716 | + | ||
| 717 | + | user, _ := testDB.RegisterUser("allpostsowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI allpostsowner", "comment") | |
| 718 | + | ||
| 719 | + | _ = mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "allpost1.md", Slug: "allpost1", Title: "All Post 1", Space: "prose"}) | |
| 720 | + | _ = mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "allpost2.md", Slug: "allpost2", Title: "All Post 2", Space: "prose"}) | |
| 721 | + | ||
| 722 | + | posts, err := testDB.FindAllPostsForUser(user.ID, "prose") | |
| 723 | + | if err != nil { | |
| 724 | + | t.Fatalf("FindAllPostsForUser failed: %v", err) | |
| 725 | + | } | |
| 726 | + | if len(posts) != 2 { | |
| 727 | + | t.Errorf("expected 2 posts, got %d", len(posts)) | |
| 728 | + | } | |
| 729 | + | } | |
| 730 | + | ||
| 731 | + | func TestFindUsersWithPost(t *testing.T) { | |
| 732 | + | cleanupTestData(t) | |
| 733 | + | ||
| 734 | + | user, _ := testDB.RegisterUser("feedspostowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI feedspostowner", "comment") | |
| 735 | + | ||
| 736 | + | _ = mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "feed.txt", Slug: "feed", Title: "Feed", Space: "feeds"}) | |
| 737 | + | ||
| 738 | + | users, err := testDB.FindUsersWithPost("feeds") | |
| 739 | + | if err != nil { | |
| 740 | + | t.Fatalf("FindUsersWithPost failed: %v", err) | |
| 741 | + | } | |
| 742 | + | if len(users) != 1 { | |
| 743 | + | t.Errorf("expected 1 user, got %d", len(users)) | |
| 744 | + | } | |
| 745 | + | } | |
| 746 | + | ||
| 747 | + | func TestFindExpiredPosts(t *testing.T) { | |
| 748 | + | cleanupTestData(t) | |
| 749 | + | ||
| 750 | + | user, _ := testDB.RegisterUser("expiredpostowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI expiredpostowner", "comment") | |
| 751 | + | ||
| 752 | + | expired := time.Now().Add(-24 * time.Hour) | |
| 753 | + | _ = mustInsertPost(t, &db.Post{ | |
| 754 | + | UserID: user.ID, | |
| 755 | + | Filename: "expired.txt", | |
| 756 | + | Slug: "expired", | |
| 757 | + | Title: "Expired", | |
| 758 | + | Space: "pastes", | |
| 759 | + | ExpiresAt: &expired, | |
| 760 | + | }) | |
| 761 | + | ||
| 762 | + | posts, err := testDB.FindExpiredPosts("pastes") | |
| 763 | + | if err != nil { | |
| 764 | + | t.Fatalf("FindExpiredPosts failed: %v", err) | |
| 765 | + | } | |
| 766 | + | if len(posts) != 1 { | |
| 767 | + | t.Errorf("expected 1 expired post, got %d", len(posts)) | |
| 768 | + | } | |
| 769 | + | } | |
| 770 | + | ||
| 771 | + | func TestFindPostsForFeed(t *testing.T) { | |
| 772 | + | cleanupTestData(t) | |
| 773 | + | ||
| 774 | + | user, _ := testDB.RegisterUser("feedowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI feedowner", "comment") | |
| 775 | + | ||
| 776 | + | now := time.Now() | |
| 777 | + | _ = mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "feedpost.md", Slug: "feedpost", Title: "Feed Post", Space: "prose", PublishAt: &now}) | |
| 778 | + | ||
| 779 | + | pager := &db.Pager{Num: 10, Page: 0} | |
| 780 | + | result, err := testDB.FindPostsForFeed(pager, "prose") | |
| 781 | + | if err != nil { | |
| 782 | + | t.Fatalf("FindPostsForFeed failed: %v", err) | |
| 783 | + | } | |
| 784 | + | if len(result.Data) < 1 { | |
| 785 | + | t.Errorf("expected at least 1 post in feed, got %d", len(result.Data)) | |
| 786 | + | } | |
| 787 | + | } | |
| 788 | + | ||
| 789 | + | // ============ Tags Tests ============ | |
| 790 | + | ||
| 791 | + | func TestReplaceTagsForPost(t *testing.T) { | |
| 792 | + | cleanupTestData(t) | |
| 793 | + | ||
| 794 | + | user, _ := testDB.RegisterUser("tagspostowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI tagspostowner", "comment") | |
| 795 | + | post := mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "tagged.md", Slug: "tagged", Title: "Tagged", Space: "prose"}) | |
| 796 | + | ||
| 797 | + | err := testDB.ReplaceTagsForPost([]string{"tag1", "tag2"}, post.ID) | |
| 798 | + | if err != nil { | |
| 799 | + | t.Fatalf("ReplaceTagsForPost failed: %v", err) | |
| 800 | + | } | |
| 801 | + | ||
| 802 | + | found, _ := testDB.FindPostWithFilename("tagged.md", user.ID, "prose") | |
| 803 | + | if len(found.Tags) != 2 { | |
| 804 | + | t.Errorf("expected 2 tags, got %d", len(found.Tags)) | |
| 805 | + | } | |
| 806 | + | } | |
| 807 | + | ||
| 808 | + | func TestFindUserPostsByTag(t *testing.T) { | |
| 809 | + | cleanupTestData(t) | |
| 810 | + | ||
| 811 | + | user, _ := testDB.RegisterUser("usertagowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI usertagowner", "comment") | |
| 812 | + | now := time.Now() | |
| 813 | + | post := mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "usertag.md", Slug: "usertag", Title: "User Tag", Space: "prose", PublishAt: &now}) | |
| 814 | + | _ = testDB.ReplaceTagsForPost([]string{"mytag"}, post.ID) | |
| 815 | + | ||
| 816 | + | pager := &db.Pager{Num: 10, Page: 0} | |
| 817 | + | result, err := testDB.FindUserPostsByTag(pager, "mytag", user.ID, "prose") | |
| 818 | + | if err != nil { | |
| 819 | + | t.Fatalf("FindUserPostsByTag failed: %v", err) | |
| 820 | + | } | |
| 821 | + | if len(result.Data) != 1 { | |
| 822 | + | t.Errorf("expected 1 post with tag, got %d", len(result.Data)) | |
| 823 | + | } | |
| 824 | + | } | |
| 825 | + | ||
| 826 | + | func TestFindPostsByTag(t *testing.T) { | |
| 827 | + | cleanupTestData(t) | |
| 828 | + | ||
| 829 | + | user, _ := testDB.RegisterUser("tagsearchowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI tagsearchowner", "comment") | |
| 830 | + | now := time.Now() | |
| 831 | + | post := mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "tagsearch.md", Slug: "tagsearch", Title: "Tag Search", Space: "prose", PublishAt: &now}) | |
| 832 | + | _ = testDB.ReplaceTagsForPost([]string{"searchtag"}, post.ID) | |
| 833 | + | ||
| 834 | + | pager := &db.Pager{Num: 10, Page: 0} | |
| 835 | + | result, err := testDB.FindPostsByTag(pager, "searchtag", "prose") | |
| 836 | + | if err != nil { | |
| 837 | + | t.Fatalf("FindPostsByTag failed: %v", err) | |
| 838 | + | } | |
| 839 | + | if len(result.Data) != 1 { | |
| 840 | + | t.Errorf("expected 1 post with tag, got %d", len(result.Data)) | |
| 841 | + | } | |
| 842 | + | } | |
| 843 | + | ||
| 844 | + | func TestFindPopularTags(t *testing.T) { | |
| 845 | + | cleanupTestData(t) | |
| 846 | + | ||
| 847 | + | user, _ := testDB.RegisterUser("populartagowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI populartagowner", "comment") | |
| 848 | + | post1 := mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "pop1.md", Slug: "pop1", Title: "Pop 1", Space: "prose"}) | |
| 849 | + | post2 := mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "pop2.md", Slug: "pop2", Title: "Pop 2", Space: "prose"}) | |
| 850 | + | _ = testDB.ReplaceTagsForPost([]string{"popular"}, post1.ID) | |
| 851 | + | _ = testDB.ReplaceTagsForPost([]string{"popular"}, post2.ID) | |
| 852 | + | ||
| 853 | + | tags, err := testDB.FindPopularTags("prose") | |
| 854 | + | if err != nil { | |
| 855 | + | t.Fatalf("FindPopularTags failed: %v", err) | |
| 856 | + | } | |
| 857 | + | if len(tags) < 1 { | |
| 858 | + | t.Errorf("expected at least 1 popular tag, got %d", len(tags)) | |
| 859 | + | } | |
| 860 | + | } | |
| 861 | + | ||
| 862 | + | // ============ Aliases Tests ============ | |
| 863 | + | ||
| 864 | + | func TestReplaceAliasesForPost(t *testing.T) { | |
| 865 | + | cleanupTestData(t) | |
| 866 | + | ||
| 867 | + | user, _ := testDB.RegisterUser("aliasowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI aliasowner", "comment") | |
| 868 | + | post := mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "aliased.md", Slug: "aliased", Title: "Aliased", Space: "prose"}) | |
| 869 | + | ||
| 870 | + | err := testDB.ReplaceAliasesForPost([]string{"alias1", "alias2"}, post.ID) | |
| 871 | + | if err != nil { | |
| 872 | + | t.Fatalf("ReplaceAliasesForPost failed: %v", err) | |
| 873 | + | } | |
| 874 | + | } | |
| 875 | + | ||
| 876 | + | func TestFindPostWithSlug_Alias(t *testing.T) { | |
| 877 | + | cleanupTestData(t) | |
| 878 | + | ||
| 879 | + | user, _ := testDB.RegisterUser("aliassearchowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI aliassearchowner", "comment") | |
| 880 | + | post := mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "original.md", Slug: "original", Title: "Original", Space: "prose"}) | |
| 881 | + | _ = testDB.ReplaceAliasesForPost([]string{"my-alias"}, post.ID) | |
| 882 | + | ||
| 883 | + | found, err := testDB.FindPostWithSlug("my-alias", user.ID, "prose") | |
| 884 | + | if err != nil { | |
| 885 | + | t.Fatalf("FindPostWithSlug for alias failed: %v", err) | |
| 886 | + | } | |
| 887 | + | if found.Title != "Original" { | |
| 888 | + | t.Errorf("expected title 'Original', got '%s'", found.Title) | |
| 889 | + | } | |
| 890 | + | } | |
| 891 | + | ||
| 892 | + | // ============ Analytics Tests ============ | |
| 893 | + | ||
| 894 | + | func TestInsertVisit(t *testing.T) { | |
| 895 | + | cleanupTestData(t) | |
| 896 | + | ||
| 897 | + | user, _ := testDB.RegisterUser("visitowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI visitowner", "comment") | |
| 898 | + | ||
| 899 | + | visit := &db.AnalyticsVisits{ | |
| 900 | + | UserID: user.ID, | |
| 901 | + | Host: "example.com", | |
| 902 | + | Path: "/test", | |
| 903 | + | IpAddress: "192.168.1.1", | |
| 904 | + | UserAgent: "TestAgent/1.0", | |
| 905 | + | Referer: "https://referrer.com", | |
| 906 | + | Status: 200, | |
| 907 | + | } | |
| 908 | + | ||
| 909 | + | err := testDB.InsertVisit(visit) | |
| 910 | + | if err != nil { | |
| 911 | + | t.Fatalf("InsertVisit failed: %v", err) | |
| 912 | + | } | |
| 913 | + | } | |
| 914 | + | ||
| 915 | + | func TestVisitSummary(t *testing.T) { | |
| 916 | + | cleanupTestData(t) | |
| 917 | + | ||
| 918 | + | user, _ := testDB.RegisterUser("summaryowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI summaryowner", "comment") | |
| 919 | + | ||
| 920 | + | visit := &db.AnalyticsVisits{ | |
| 921 | + | UserID: user.ID, | |
| 922 | + | Host: "summary.com", | |
| 923 | + | Path: "/page", | |
| 924 | + | IpAddress: "192.168.1.2", | |
| 925 | + | Status: 200, | |
| 926 | + | } | |
| 927 | + | _ = testDB.InsertVisit(visit) | |
| 928 | + | ||
| 929 | + | opts := &db.SummaryOpts{ | |
| 930 | + | Interval: "day", | |
| 931 | + | Origin: time.Now().Add(-24 * time.Hour), | |
| 932 | + | Host: "summary.com", | |
| 933 | + | UserID: user.ID, | |
| 934 | + | } | |
| 935 | + | ||
| 936 | + | summary, err := testDB.VisitSummary(opts) | |
| 937 | + | if err != nil { | |
| 938 | + | t.Fatalf("VisitSummary failed: %v", err) | |
| 939 | + | } | |
| 940 | + | if summary == nil { | |
| 941 | + | t.Error("expected summary, got nil") | |
| 942 | + | } | |
| 943 | + | } | |
| 944 | + | ||
| 945 | + | func TestFindVisitSiteList(t *testing.T) { | |
| 946 | + | cleanupTestData(t) | |
| 947 | + | ||
| 948 | + | user, _ := testDB.RegisterUser("sitelistowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI sitelistowner", "comment") | |
| 949 | + | ||
| 950 | + | _ = testDB.InsertVisit(&db.AnalyticsVisits{ | |
| 951 | + | UserID: user.ID, | |
| 952 | + | Host: "site1.com", | |
| 953 | + | Path: "/", | |
| 954 | + | IpAddress: "192.168.1.3", | |
| 955 | + | Status: 200, | |
| 956 | + | }) | |
| 957 | + | ||
| 958 | + | opts := &db.SummaryOpts{UserID: user.ID} | |
| 959 | + | sites, err := testDB.FindVisitSiteList(opts) | |
| 960 | + | if err != nil { | |
| 961 | + | t.Fatalf("FindVisitSiteList failed: %v", err) | |
| 962 | + | } | |
| 963 | + | if len(sites) < 1 { | |
| 964 | + | t.Errorf("expected at least 1 site, got %d", len(sites)) | |
| 965 | + | } | |
| 966 | + | } | |
| 967 | + | ||
| 968 | + | func TestVisitUrlNotFound(t *testing.T) { | |
| 969 | + | cleanupTestData(t) | |
| 970 | + | ||
| 971 | + | user, _ := testDB.RegisterUser("notfoundowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI notfoundowner", "comment") | |
| 972 | + | ||
| 973 | + | _ = testDB.InsertVisit(&db.AnalyticsVisits{ | |
| 974 | + | UserID: user.ID, | |
| 975 | + | Host: "notfound.com", | |
| 976 | + | Path: "/missing", | |
| 977 | + | IpAddress: "192.168.1.4", | |
| 978 | + | Status: 404, | |
| 979 | + | }) | |
| 980 | + | ||
| 981 | + | opts := &db.SummaryOpts{ | |
| 982 | + | Origin: time.Now().Add(-24 * time.Hour), | |
| 983 | + | Host: "notfound.com", | |
| 984 | + | UserID: user.ID, | |
| 985 | + | } | |
| 986 | + | notFound, err := testDB.VisitUrlNotFound(opts) | |
| 987 | + | if err != nil { | |
| 988 | + | t.Fatalf("VisitUrlNotFound failed: %v", err) | |
| 989 | + | } | |
| 990 | + | if len(notFound) < 1 { | |
| 991 | + | t.Errorf("expected at least 1 not found URL, got %d", len(notFound)) | |
| 992 | + | } | |
| 993 | + | } | |
| 994 | + | ||
| 995 | + | // ============ Features Tests ============ | |
| 996 | + | ||
| 997 | + | func TestInsertFeature(t *testing.T) { | |
| 998 | + | cleanupTestData(t) | |
| 999 | + | ||
| 1000 | + | user, _ := testDB.RegisterUser("featureowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI featureowner", "comment") | |
| 1001 | + | ||
| 1002 | + | expiresAt := time.Now().Add(365 * 24 * time.Hour) | |
| 1003 | + | feature, err := testDB.InsertFeature(user.ID, "plus", expiresAt) | |
| 1004 | + | if err != nil { | |
| 1005 | + | t.Fatalf("InsertFeature failed: %v", err) | |
| 1006 | + | } | |
| 1007 | + | if feature.Name != "plus" { | |
| 1008 | + | t.Errorf("expected feature name 'plus', got '%s'", feature.Name) | |
| 1009 | + | } | |
| 1010 | + | } | |
| 1011 | + | ||
| 1012 | + | func TestFindFeature(t *testing.T) { | |
| 1013 | + | cleanupTestData(t) | |
| 1014 | + | ||
| 1015 | + | user, _ := testDB.RegisterUser("findfeatureowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI findfeatureowner", "comment") | |
| 1016 | + | expiresAt := time.Now().Add(365 * 24 * time.Hour) | |
| 1017 | + | _, _ = testDB.InsertFeature(user.ID, "plus", expiresAt) | |
| 1018 | + | ||
| 1019 | + | feature, err := testDB.FindFeature(user.ID, "plus") | |
| 1020 | + | if err != nil { | |
| 1021 | + | t.Fatalf("FindFeature failed: %v", err) | |
| 1022 | + | } | |
| 1023 | + | if feature.Name != "plus" { | |
| 1024 | + | t.Errorf("expected feature name 'plus', got '%s'", feature.Name) | |
| 1025 | + | } | |
| 1026 | + | } | |
| 1027 | + | ||
| 1028 | + | func TestFindFeaturesForUser(t *testing.T) { | |
| 1029 | + | cleanupTestData(t) | |
| 1030 | + | ||
| 1031 | + | user, _ := testDB.RegisterUser("featuresowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI featuresowner", "comment") | |
| 1032 | + | expiresAt := time.Now().Add(365 * 24 * time.Hour) | |
| 1033 | + | _, _ = testDB.InsertFeature(user.ID, "plus", expiresAt) | |
| 1034 | + | _, _ = testDB.InsertFeature(user.ID, "pro", expiresAt) | |
| 1035 | + | ||
| 1036 | + | features, err := testDB.FindFeaturesForUser(user.ID) | |
| 1037 | + | if err != nil { | |
| 1038 | + | t.Fatalf("FindFeaturesForUser failed: %v", err) | |
| 1039 | + | } | |
| 1040 | + | if len(features) != 2 { | |
| 1041 | + | t.Errorf("expected 2 features, got %d", len(features)) | |
| 1042 | + | } | |
| 1043 | + | } | |
| 1044 | + | ||
| 1045 | + | func TestHasFeatureForUser(t *testing.T) { | |
| 1046 | + | cleanupTestData(t) | |
| 1047 | + | ||
| 1048 | + | user, _ := testDB.RegisterUser("hasfeatureowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI hasfeatureowner", "comment") | |
| 1049 | + | expiresAt := time.Now().Add(365 * 24 * time.Hour) | |
| 1050 | + | _, _ = testDB.InsertFeature(user.ID, "plus", expiresAt) | |
| 1051 | + | ||
| 1052 | + | has := testDB.HasFeatureForUser(user.ID, "plus") | |
| 1053 | + | if !has { | |
| 1054 | + | t.Error("expected HasFeatureForUser to return true") | |
| 1055 | + | } | |
| 1056 | + | ||
| 1057 | + | hasNot := testDB.HasFeatureForUser(user.ID, "nonexistent") | |
| 1058 | + | if hasNot { | |
| 1059 | + | t.Error("expected HasFeatureForUser to return false for nonexistent feature") | |
| 1060 | + | } | |
| 1061 | + | } | |
| 1062 | + | ||
| 1063 | + | func TestRemoveFeature(t *testing.T) { | |
| 1064 | + | cleanupTestData(t) | |
| 1065 | + | ||
| 1066 | + | user, _ := testDB.RegisterUser("removefeatureowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI removefeatureowner", "comment") | |
| 1067 | + | expiresAt := time.Now().Add(365 * 24 * time.Hour) | |
| 1068 | + | _, _ = testDB.InsertFeature(user.ID, "plus", expiresAt) | |
| 1069 | + | ||
| 1070 | + | err := testDB.RemoveFeature(user.ID, "plus") | |
| 1071 | + | if err != nil { | |
| 1072 | + | t.Fatalf("RemoveFeature failed: %v", err) | |
| 1073 | + | } | |
| 1074 | + | ||
| 1075 | + | _, err = testDB.FindFeature(user.ID, "plus") | |
| 1076 | + | if err == nil { | |
| 1077 | + | t.Error("expected error finding removed feature, got nil") | |
| 1078 | + | } | |
| 1079 | + | } | |
| 1080 | + | ||
| 1081 | + | func TestAddPicoPlusUser(t *testing.T) { | |
| 1082 | + | cleanupTestData(t) | |
| 1083 | + | ||
| 1084 | + | _, _ = testDB.RegisterUser("picoplusowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI picoplusowner", "comment") | |
| 1085 | + | ||
| 1086 | + | err := testDB.AddPicoPlusUser("picoplusowner", "test@example.com", "stripe", "tx123") | |
| 1087 | + | if err != nil { | |
| 1088 | + | t.Fatalf("AddPicoPlusUser failed: %v", err) | |
| 1089 | + | } | |
| 1090 | + | } | |
| 1091 | + | ||
| 1092 | + | // ============ Feed Items Tests ============ | |
| 1093 | + | ||
| 1094 | + | func TestInsertFeedItems(t *testing.T) { | |
| 1095 | + | cleanupTestData(t) | |
| 1096 | + | ||
| 1097 | + | user, _ := testDB.RegisterUser("feeditemsowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI feeditemsowner", "comment") | |
| 1098 | + | post := mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "feed.txt", Slug: "feed", Title: "Feed", Space: "feeds"}) | |
| 1099 | + | ||
| 1100 | + | items := []*db.FeedItem{ | |
| 1101 | + | {PostID: post.ID, GUID: "guid-1", Data: db.FeedItemData{Title: "Item 1", Link: "http://example.com/1"}}, | |
| 1102 | + | {PostID: post.ID, GUID: "guid-2", Data: db.FeedItemData{Title: "Item 2", Link: "http://example.com/2"}}, | |
| 1103 | + | } | |
| 1104 | + | ||
| 1105 | + | err := testDB.InsertFeedItems(post.ID, items) | |
| 1106 | + | if err != nil { | |
| 1107 | + | t.Fatalf("InsertFeedItems failed: %v", err) | |
| 1108 | + | } | |
| 1109 | + | } | |
| 1110 | + | ||
| 1111 | + | func TestFindFeedItemsByPostID(t *testing.T) { | |
| 1112 | + | cleanupTestData(t) | |
| 1113 | + | ||
| 1114 | + | user, _ := testDB.RegisterUser("findfeeditemsowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI findfeeditemsowner", "comment") | |
| 1115 | + | post := mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "findfeed.txt", Slug: "findfeed", Title: "Find Feed", Space: "feeds"}) | |
| 1116 | + | ||
| 1117 | + | items := []*db.FeedItem{ | |
| 1118 | + | {PostID: post.ID, GUID: "find-guid-1", Data: db.FeedItemData{Title: "Find Item 1"}}, | |
| 1119 | + | } | |
| 1120 | + | _ = testDB.InsertFeedItems(post.ID, items) | |
| 1121 | + | ||
| 1122 | + | found, err := testDB.FindFeedItemsByPostID(post.ID) | |
| 1123 | + | if err != nil { | |
| 1124 | + | t.Fatalf("FindFeedItemsByPostID failed: %v", err) | |
| 1125 | + | } | |
| 1126 | + | if len(found) != 1 { | |
| 1127 | + | t.Errorf("expected 1 feed item, got %d", len(found)) | |
| 1128 | + | } | |
| 1129 | + | } | |
| 1130 | + | ||
| 1131 | + | // ============ Projects Tests ============ | |
| 1132 | + | ||
| 1133 | + | func TestUpsertProject(t *testing.T) { | |
| 1134 | + | cleanupTestData(t) | |
| 1135 | + | ||
| 1136 | + | user, _ := testDB.RegisterUser("projectowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI projectowner", "comment") | |
| 1137 | + | ||
| 1138 | + | project, err := testDB.UpsertProject(user.ID, "my-project", "my-project") | |
| 1139 | + | if err != nil { | |
| 1140 | + | t.Fatalf("UpsertProject failed: %v", err) | |
| 1141 | + | } | |
| 1142 | + | if project.Name != "my-project" { | |
| 1143 | + | t.Errorf("expected project name 'my-project', got '%s'", project.Name) | |
| 1144 | + | } | |
| 1145 | + | ||
| 1146 | + | project2, err := testDB.UpsertProject(user.ID, "my-project", "my-project") | |
| 1147 | + | if err != nil { | |
| 1148 | + | t.Fatalf("UpsertProject (update) failed: %v", err) | |
| 1149 | + | } | |
| 1150 | + | if project2.ID != project.ID { | |
| 1151 | + | t.Error("expected same project ID on upsert") | |
| 1152 | + | } | |
| 1153 | + | } | |
| 1154 | + | ||
| 1155 | + | func TestFindProjectByName(t *testing.T) { | |
| 1156 | + | cleanupTestData(t) | |
| 1157 | + | ||
| 1158 | + | user, _ := testDB.RegisterUser("findprojectowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI findprojectowner", "comment") | |
| 1159 | + | _, _ = testDB.UpsertProject(user.ID, "findme-project", "findme-project") | |
| 1160 | + | ||
| 1161 | + | project, err := testDB.FindProjectByName(user.ID, "findme-project") | |
| 1162 | + | if err != nil { | |
| 1163 | + | t.Fatalf("FindProjectByName failed: %v", err) | |
| 1164 | + | } | |
| 1165 | + | if project.Name != "findme-project" { | |
| 1166 | + | t.Errorf("expected project name 'findme-project', got '%s'", project.Name) | |
| 1167 | + | } | |
| 1168 | + | } | |
| 1169 | + | ||
| 1170 | + | // ============ User Stats Tests ============ | |
| 1171 | + | ||
| 1172 | + | func TestFindUserStats(t *testing.T) { | |
| 1173 | + | cleanupTestData(t) | |
| 1174 | + | ||
| 1175 | + | user, _ := testDB.RegisterUser("statsowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI statsowner", "comment") | |
| 1176 | + | _ = mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "stat.md", Slug: "stat", Title: "Stat", Space: "prose"}) | |
| 1177 | + | _, _ = testDB.UpsertProject(user.ID, "stat-project", "stat-project") | |
| 1178 | + | ||
| 1179 | + | stats, err := testDB.FindUserStats(user.ID) | |
| 1180 | + | if err != nil { | |
| 1181 | + | t.Fatalf("FindUserStats failed: %v", err) | |
| 1182 | + | } | |
| 1183 | + | if stats.Prose.Num != 1 { | |
| 1184 | + | t.Errorf("expected 1 prose post, got %d", stats.Prose.Num) | |
| 1185 | + | } | |
| 1186 | + | if stats.Pages.Num != 1 { | |
| 1187 | + | t.Errorf("expected 1 project, got %d", stats.Pages.Num) | |
| 1188 | + | } | |
| 1189 | + | } | |
| 1190 | + | ||
| 1191 | + | // ============ Tuns Event Logs Tests ============ | |
| 1192 | + | ||
| 1193 | + | func TestInsertTunsEventLog(t *testing.T) { | |
| 1194 | + | cleanupTestData(t) | |
| 1195 | + | ||
| 1196 | + | user, _ := testDB.RegisterUser("tunsowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI tunsowner", "comment") | |
| 1197 | + | ||
| 1198 | + | log := &db.TunsEventLog{ | |
| 1199 | + | UserId: user.ID, | |
| 1200 | + | ServerID: "server-1", | |
| 1201 | + | RemoteAddr: "192.168.1.1:1234", | |
| 1202 | + | EventType: "connect", | |
| 1203 | + | TunnelType: "http", | |
| 1204 | + | ConnectionType: "tcp", | |
| 1205 | + | TunnelID: "tunnel-123", | |
| 1206 | + | } | |
| 1207 | + | ||
| 1208 | + | err := testDB.InsertTunsEventLog(log) | |
| 1209 | + | if err != nil { | |
| 1210 | + | t.Fatalf("InsertTunsEventLog failed: %v", err) | |
| 1211 | + | } | |
| 1212 | + | } | |
| 1213 | + | ||
| 1214 | + | func TestFindTunsEventLogs(t *testing.T) { | |
| 1215 | + | cleanupTestData(t) | |
| 1216 | + | ||
| 1217 | + | user, _ := testDB.RegisterUser("findtunsowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI findtunsowner", "comment") | |
| 1218 | + | _ = testDB.InsertTunsEventLog(&db.TunsEventLog{ | |
| 1219 | + | UserId: user.ID, | |
| 1220 | + | ServerID: "server-1", | |
| 1221 | + | RemoteAddr: "192.168.1.1:1234", | |
| 1222 | + | EventType: "connect", | |
| 1223 | + | TunnelType: "http", | |
| 1224 | + | ConnectionType: "tcp", | |
| 1225 | + | TunnelID: "tunnel-456", | |
| 1226 | + | }) | |
| 1227 | + | ||
| 1228 | + | logs, err := testDB.FindTunsEventLogs(user.ID) | |
| 1229 | + | if err != nil { | |
| 1230 | + | t.Fatalf("FindTunsEventLogs failed: %v", err) | |
| 1231 | + | } | |
| 1232 | + | if len(logs) != 1 { | |
| 1233 | + | t.Errorf("expected 1 log, got %d", len(logs)) | |
| 1234 | + | } | |
| 1235 | + | } | |
| 1236 | + | ||
| 1237 | + | func TestFindTunsEventLogsByAddr(t *testing.T) { | |
| 1238 | + | cleanupTestData(t) | |
| 1239 | + | ||
| 1240 | + | user, _ := testDB.RegisterUser("tunsaddrowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI tunsaddrowner", "comment") | |
| 1241 | + | _ = testDB.InsertTunsEventLog(&db.TunsEventLog{ | |
| 1242 | + | UserId: user.ID, | |
| 1243 | + | ServerID: "server-1", | |
| 1244 | + | RemoteAddr: "192.168.1.1:1234", | |
| 1245 | + | EventType: "connect", | |
| 1246 | + | TunnelType: "http", | |
| 1247 | + | ConnectionType: "tcp", | |
| 1248 | + | TunnelID: "tunnel-789", | |
| 1249 | + | }) | |
| 1250 | + | ||
| 1251 | + | logs, err := testDB.FindTunsEventLogsByAddr(user.ID, "tunnel-789") | |
| 1252 | + | if err != nil { | |
| 1253 | + | t.Fatalf("FindTunsEventLogsByAddr failed: %v", err) | |
| 1254 | + | } | |
| 1255 | + | if len(logs) != 1 { | |
| 1256 | + | t.Errorf("expected 1 log, got %d", len(logs)) | |
| 1257 | + | } | |
| 1258 | + | } | |
| 1259 | + | ||
| 1260 | + | // ============ Access Logs Tests ============ | |
| 1261 | + | ||
| 1262 | + | func TestInsertAccessLog(t *testing.T) { | |
| 1263 | + | cleanupTestData(t) | |
| 1264 | + | ||
| 1265 | + | user, _ := testDB.RegisterUser("accesslogowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI accesslogowner", "comment") | |
| 1266 | + | ||
| 1267 | + | log := &db.AccessLog{ | |
| 1268 | + | UserID: user.ID, | |
| 1269 | + | Service: "pgs", | |
| 1270 | + | Pubkey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI accesslogowner", | |
| 1271 | + | Identity: "accesslogowner", | |
| 1272 | + | } | |
| 1273 | + | ||
| 1274 | + | err := testDB.InsertAccessLog(log) | |
| 1275 | + | if err != nil { | |
| 1276 | + | t.Fatalf("InsertAccessLog failed: %v", err) | |
| 1277 | + | } | |
| 1278 | + | } | |
| 1279 | + | ||
| 1280 | + | func TestFindAccessLogs(t *testing.T) { | |
| 1281 | + | cleanupTestData(t) | |
| 1282 | + | ||
| 1283 | + | user, _ := testDB.RegisterUser("findaccesslogowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI findaccesslogowner", "comment") | |
| 1284 | + | _ = testDB.InsertAccessLog(&db.AccessLog{ | |
| 1285 | + | UserID: user.ID, | |
| 1286 | + | Service: "pgs", | |
| 1287 | + | Pubkey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI findaccesslogowner", | |
| 1288 | + | Identity: "findaccesslogowner", | |
| 1289 | + | }) | |
| 1290 | + | ||
| 1291 | + | fromDate := time.Now().Add(-24 * time.Hour) | |
| 1292 | + | logs, err := testDB.FindAccessLogs(user.ID, &fromDate) | |
| 1293 | + | if err != nil { | |
| 1294 | + | t.Fatalf("FindAccessLogs failed: %v", err) | |
| 1295 | + | } | |
| 1296 | + | if len(logs) != 1 { | |
| 1297 | + | t.Errorf("expected 1 log, got %d", len(logs)) | |
| 1298 | + | } | |
| 1299 | + | } | |
| 1300 | + | ||
| 1301 | + | func TestFindPubkeysInAccessLogs(t *testing.T) { | |
| 1302 | + | cleanupTestData(t) | |
| 1303 | + | ||
| 1304 | + | user, _ := testDB.RegisterUser("pubkeylogowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI pubkeylogowner", "comment") | |
| 1305 | + | _ = testDB.InsertAccessLog(&db.AccessLog{ | |
| 1306 | + | UserID: user.ID, | |
| 1307 | + | Service: "pgs", | |
| 1308 | + | Pubkey: "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI pubkeylogowner", | |
| 1309 | + | Identity: "pubkeylogowner", | |
| 1310 | + | }) | |
| 1311 | + | ||
| 1312 | + | pubkeys, err := testDB.FindPubkeysInAccessLogs(user.ID) | |
| 1313 | + | if err != nil { | |
| 1314 | + | t.Fatalf("FindPubkeysInAccessLogs failed: %v", err) | |
| 1315 | + | } | |
| 1316 | + | if len(pubkeys) != 1 { | |
| 1317 | + | t.Errorf("expected 1 pubkey, got %d", len(pubkeys)) | |
| 1318 | + | } | |
| 1319 | + | } | |
| 1320 | + | ||
| 1321 | + | func TestFindAccessLogsByPubkey(t *testing.T) { | |
| 1322 | + | cleanupTestData(t) | |
| 1323 | + | ||
| 1324 | + | user, _ := testDB.RegisterUser("accessbypubkeyowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI accessbypubkeyowner", "comment") | |
| 1325 | + | pubkey := "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI accessbypubkeyowner" | |
| 1326 | + | _ = testDB.InsertAccessLog(&db.AccessLog{ | |
| 1327 | + | UserID: user.ID, | |
| 1328 | + | Service: "pgs", | |
| 1329 | + | Pubkey: pubkey, | |
| 1330 | + | Identity: "accessbypubkeyowner", | |
| 1331 | + | }) | |
| 1332 | + | ||
| 1333 | + | fromDate := time.Now().Add(-24 * time.Hour) | |
| 1334 | + | logs, err := testDB.FindAccessLogsByPubkey(pubkey, &fromDate) | |
| 1335 | + | if err != nil { | |
| 1336 | + | t.Fatalf("FindAccessLogsByPubkey failed: %v", err) | |
| 1337 | + | } | |
| 1338 | + | if len(logs) != 1 { | |
| 1339 | + | t.Errorf("expected 1 log, got %d", len(logs)) | |
| 1340 | + | } | |
| 1341 | + | } | |
| 1342 | + | ||
| 1343 | + | // ============ JSONB Roundtrip Tests ============ | |
| 1344 | + | ||
| 1345 | + | func TestPostData_JSONBRoundtrip(t *testing.T) { | |
| 1346 | + | cleanupTestData(t) | |
| 1347 | + | ||
| 1348 | + | user, _ := testDB.RegisterUser("postdataowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI postdataowner", "comment") | |
| 1349 | + | ||
| 1350 | + | now := time.Now().Truncate(time.Second) | |
| 1351 | + | postData := db.PostData{ | |
| 1352 | + | ImgPath: "/images/test.png", | |
| 1353 | + | LastDigest: &now, | |
| 1354 | + | Attempts: 5, | |
| 1355 | + | } | |
| 1356 | + | ||
| 1357 | + | post := mustInsertPost(t, &db.Post{ | |
| 1358 | + | UserID: user.ID, | |
| 1359 | + | Filename: "jsonb.md", | |
| 1360 | + | Slug: "jsonb", | |
| 1361 | + | Title: "JSONB Test", | |
| 1362 | + | Space: "prose", | |
| 1363 | + | Data: postData, | |
| 1364 | + | }) | |
| 1365 | + | ||
| 1366 | + | found, err := testDB.FindPost(post.ID) | |
| 1367 | + | if err != nil { | |
| 1368 | + | t.Fatalf("FindPost failed: %v", err) | |
| 1369 | + | } | |
| 1370 | + | if found.Data.ImgPath != "/images/test.png" { | |
| 1371 | + | t.Errorf("expected ImgPath '/images/test.png', got '%s'", found.Data.ImgPath) | |
| 1372 | + | } | |
| 1373 | + | if found.Data.Attempts != 5 { | |
| 1374 | + | t.Errorf("expected Attempts 5, got %d", found.Data.Attempts) | |
| 1375 | + | } | |
| 1376 | + | } | |
| 1377 | + | ||
| 1378 | + | func TestProjectAcl_JSONBRoundtrip(t *testing.T) { | |
| 1379 | + | cleanupTestData(t) | |
| 1380 | + | ||
| 1381 | + | user, _ := testDB.RegisterUser("aclowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI aclowner", "comment") | |
| 1382 | + | ||
| 1383 | + | project, err := testDB.UpsertProject(user.ID, "acl-project", "acl-project") | |
| 1384 | + | if err != nil { | |
| 1385 | + | t.Fatalf("UpsertProject failed: %v", err) | |
| 1386 | + | } | |
| 1387 | + | ||
| 1388 | + | found, err := testDB.FindProjectByName(user.ID, "acl-project") | |
| 1389 | + | if err != nil { | |
| 1390 | + | t.Fatalf("FindProjectByName failed: %v", err) | |
| 1391 | + | } | |
| 1392 | + | if found.Acl.Type != "public" { | |
| 1393 | + | t.Errorf("expected Acl.Type 'public', got '%s'", found.Acl.Type) | |
| 1394 | + | } | |
| 1395 | + | _ = project | |
| 1396 | + | } | |
| 1397 | + | ||
| 1398 | + | func TestFeedItemData_JSONBRoundtrip(t *testing.T) { | |
| 1399 | + | cleanupTestData(t) | |
| 1400 | + | ||
| 1401 | + | user, _ := testDB.RegisterUser("feedjsonbowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI feedjsonbowner", "comment") | |
| 1402 | + | post := mustInsertPost(t, &db.Post{UserID: user.ID, Filename: "feedjsonb.txt", Slug: "feedjsonb", Title: "Feed JSONB", Space: "feeds"}) | |
| 1403 | + | ||
| 1404 | + | now := time.Now().Truncate(time.Second) | |
| 1405 | + | items := []*db.FeedItem{ | |
| 1406 | + | { | |
| 1407 | + | PostID: post.ID, | |
| 1408 | + | GUID: "jsonb-guid", | |
| 1409 | + | Data: db.FeedItemData{ | |
| 1410 | + | Title: "JSONB Item", | |
| 1411 | + | Description: "Description", | |
| 1412 | + | Content: "Content", | |
| 1413 | + | Link: "http://example.com", | |
| 1414 | + | PublishedAt: &now, | |
| 1415 | + | }, | |
| 1416 | + | }, | |
| 1417 | + | } | |
| 1418 | + | _ = testDB.InsertFeedItems(post.ID, items) | |
| 1419 | + | ||
| 1420 | + | found, err := testDB.FindFeedItemsByPostID(post.ID) | |
| 1421 | + | if err != nil { | |
| 1422 | + | t.Fatalf("FindFeedItemsByPostID failed: %v", err) | |
| 1423 | + | } | |
| 1424 | + | if len(found) != 1 { | |
| 1425 | + | t.Fatalf("expected 1 item, got %d", len(found)) | |
| 1426 | + | } | |
| 1427 | + | if found[0].Data.Title != "JSONB Item" { | |
| 1428 | + | t.Errorf("expected title 'JSONB Item', got '%s'", found[0].Data.Title) | |
| 1429 | + | } | |
| 1430 | + | } | |
| 1431 | + | ||
| 1432 | + | func TestFeatureFlagData_JSONBRoundtrip(t *testing.T) { | |
| 1433 | + | cleanupTestData(t) | |
| 1434 | + | ||
| 1435 | + | user, _ := testDB.RegisterUser("featurejsonbowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI featurejsonbowner", "comment") | |
| 1436 | + | ||
| 1437 | + | err := testDB.AddPicoPlusUser("featurejsonbowner", "test@example.com", "stripe", "tx456") | |
| 1438 | + | if err != nil { | |
| 1439 | + | t.Fatalf("AddPicoPlusUser failed: %v", err) | |
| 1440 | + | } | |
| 1441 | + | ||
| 1442 | + | feature, err := testDB.FindFeature(user.ID, "plus") | |
| 1443 | + | if err != nil { | |
| 1444 | + | t.Fatalf("FindFeature failed: %v", err) | |
| 1445 | + | } | |
| 1446 | + | if feature.Data.StorageMax != 10000000000 { | |
| 1447 | + | t.Errorf("expected StorageMax 10000000000, got %d", feature.Data.StorageMax) | |
| 1448 | + | } | |
| 1449 | + | if feature.Data.FileMax != 50000000 { | |
| 1450 | + | t.Errorf("expected FileMax 50000000, got %d", feature.Data.FileMax) | |
| 1451 | + | } | |
| 1452 | + | } | |
| 1453 | + | ||
| 1454 | + | func TestPaymentHistoryData_JSONBRoundtrip(t *testing.T) { | |
| 1455 | + | cleanupTestData(t) | |
| 1456 | + | ||
| 1457 | + | user, _ := testDB.RegisterUser("paymentjsonbowner", "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI paymentjsonbowner", "comment") | |
| 1458 | + | ||
| 1459 | + | err := testDB.AddPicoPlusUser("paymentjsonbowner", "payment@example.com", "stripe", "tx789") | |
| 1460 | + | if err != nil { | |
| 1461 | + | t.Fatalf("AddPicoPlusUser failed: %v", err) | |
| 1462 | + | } | |
| 1463 | + | ||
| 1464 | + | var txId string | |
| 1465 | + | err = testDB.Db.QueryRow("SELECT data->>'tx_id' FROM payment_history WHERE user_id = $1", user.ID).Scan(&txId) | |
| 1466 | + | if err != nil { | |
| 1467 | + | t.Fatalf("failed to query payment history: %v", err) | |
| 1468 | + | } | |
| 1469 | + | if txId != "tx789" { | |
| 1470 | + | t.Errorf("expected tx_id 'tx789', got '%s'", txId) | |
| 1471 | + | } | |
| 1472 | + | } |