Skip to content

Commit

Permalink
feat: test analyze image with testconteiners (#29)
Browse files Browse the repository at this point in the history
* doc: numbering

* doc: line webhook sample

* feat: config env

* feat: go get testcontainer httpmock

* feat: rename handler to router

* feat: gcs mocking

* feat: mock line

* feat: mock pubsub

* fix: lint

* chore: logging
  • Loading branch information
kyong0612 authored Jan 10, 2024
1 parent 1dad95e commit 32a35f1
Show file tree
Hide file tree
Showing 18 changed files with 336 additions and 28 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ENV=local
LINE_CHANNEL_SECRET=YOUR_CHANNEL_SECRET
LINE_CHANNEL_ACCESS_TOKEN=YOUR_CHANNEL_ACCESS_TOKEN
GEMINI_API_KEY=YOUR_GEMINI_API_KEY
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
49 changes: 49 additions & 0 deletions docs/6-line-webhook-sample.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# line webhook sample

- dump request

```bash
POST /line/webhook HTTP/1.1
Host: fitness-supporter-prod-x4zvxzl3ua-an.a.run.app
Content-Length: 564
Content-Type: application/json; charset=utf-8
Forwarded: for="147.92.149.166";proto=https
Traceparent: 00-581f9dfc02c2a06c332a2e6c7e628e6f-ab46feec28c3abad-01
User-Agent: LineBotWebhook/2.0
X-Cloud-Trace-Context: 581f9dfc02c2a06c332a2e6c7e628e6f/12341832119105072045;o=1
X-Forwarded-For: 147.92.149.166
X-Forwarded-Proto: https
X-Line-Signature: SPF+aswY1QKSO41ERcOs3IDju6ZkLHYDhKPbe6RUsZw=

{"destination":"Ued4095ce4cf48cdb76b561d079297db7","events":[{"type":"message","message":{"type":"text","id":"488830589727146065","quoteToken":"xxxxxxxx","text":"asdfadfa"},"webhookEventId":"01HK50YAT7682957NXRYYNARM6","deliveryContext":{"isRedelivery":false},"timestamp":1704197040565,"source":{"type":"user","userId":"Ub3460cc5512a5791102446b8d075b066"},"replyToken":"xxxxxx","mode":"active"}]}
```

- payload

```bash
{
"destination": "Ued4095ce4cf48cdb76b561d079297db7",
"events": [
{
"type": "message",
"message": {
"type": "text",
"id": "488830589727146065",
"quoteToken": "xxxxxxxx",
"text": "asdfadfa"
},
"webhookEventId": "01HK50YAT7682957NXRYYNARM6",
"deliveryContext": {
"isRedelivery": false
},
"timestamp": 1704197040565,
"source": {
"type": "user",
"userId": "Ub3460cc5512a5791102446b8d075b066"
},
"replyToken": "xxxxxx",
"mode": "active"
}
]
}
```
38 changes: 29 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ require (
github.com/golangci/golangci-lint v1.55.1
github.com/google/generative-ai-go v0.5.0
github.com/google/uuid v1.5.0
github.com/jarcoal/httpmock v1.3.1
github.com/line/line-bot-sdk-go/v8 v8.2.0
golang.org/x/net v0.20.0
github.com/testcontainers/testcontainers-go v0.27.0
github.com/testcontainers/testcontainers-go/modules/gcloud v0.27.0
golang.org/x/net v0.19.0
golang.org/x/vuln v1.0.1
google.golang.org/api v0.155.0
google.golang.org/grpc v1.60.1
google.golang.org/protobuf v1.32.0
)

Expand All @@ -33,6 +37,7 @@ require (
cloud.google.com/go/iam v1.1.5 // indirect
cloud.google.com/go/longrunning v0.5.4 // indirect
connectrpc.com/otelconnect v0.6.0 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/4meepo/tagalign v1.3.3 // indirect
github.com/Abirdcfly/dupword v0.0.13 // indirect
github.com/Antonboom/errname v0.1.12 // indirect
Expand All @@ -44,6 +49,7 @@ require (
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.1.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/OpenPeeDeeP/depguard/v2 v2.1.0 // indirect
github.com/alecthomas/go-check-sumtype v0.1.3 // indirect
github.com/alexkohler/nakedret/v2 v2.0.2 // indirect
Expand All @@ -64,6 +70,7 @@ require (
github.com/butuzov/mirror v1.1.0 // indirect
github.com/catenacyber/perfsprint v0.2.0 // indirect
github.com/ccojocar/zxcvbn-go v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/census-instrumentation/opencensus-proto v0.4.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/charithe/durationcheck v0.0.10 // indirect
Expand All @@ -72,7 +79,10 @@ require (
github.com/cncf/xds/go v0.0.0-20230607035331-e9ce68804cb4 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/containerd/containerd v1.7.11 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.15.1 // indirect
github.com/cpuguy83/dockercfg v0.3.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect
github.com/curioswitch/go-reassign v0.2.0 // indirect
github.com/daixiang0/gci v0.11.2 // indirect
Expand All @@ -94,14 +104,15 @@ require (
github.com/felixge/fgprof v0.9.3 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/firefart/nonamedreturns v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/ghostiam/protogetter v0.2.3 // indirect
github.com/go-chi/chi/v5 v5.0.10 // indirect
github.com/go-critic/go-critic v0.9.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-toolsmith/astcast v1.1.0 // indirect
github.com/go-toolsmith/astcopy v1.1.0 // indirect
github.com/go-toolsmith/astequal v1.1.0 // indirect
Expand Down Expand Up @@ -137,7 +148,7 @@ require (
github.com/gostaticanalysis/comment v1.4.2 // indirect
github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand All @@ -163,19 +174,22 @@ require (
github.com/ldez/tagliatelle v0.5.0 // indirect
github.com/leonklingele/grouper v1.1.1 // indirect
github.com/lufeee/execinquery v1.2.1 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/macabu/inamedparam v0.1.2 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/maratori/testableexamples v1.0.0 // indirect
github.com/maratori/testpackage v1.1.1 // indirect
github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mbilski/exhaustivestruct v1.2.0 // indirect
github.com/mgechev/revive v1.3.4 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/moricho/tparallel v0.3.1 // indirect
github.com/morikuni/aec v1.0.0 // indirect
Expand All @@ -186,17 +200,19 @@ require (
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/profile v1.7.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.4.5 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/quasilyte/go-ruleguard v0.4.0 // indirect
github.com/quasilyte/gogrep v0.5.0 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
Expand All @@ -211,6 +227,8 @@ require (
github.com/sashamelentyev/usestdlibvars v1.24.0 // indirect
github.com/securego/gosec/v2 v2.18.2 // indirect
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
github.com/shirou/gopsutil/v3 v3.23.11 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sivchari/containedctx v1.0.3 // indirect
github.com/sivchari/nosnakecase v1.7.0 // indirect
Expand All @@ -235,6 +253,8 @@ require (
github.com/tetratelabs/wazero v1.5.0 // indirect
github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 // indirect
github.com/timonwong/loggercheck v0.9.4 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tomarrell/wrapcheck/v2 v2.8.1 // indirect
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
github.com/ultraware/funlen v0.1.0 // indirect
Expand All @@ -245,6 +265,7 @@ require (
github.com/yagipy/maintidx v1.0.0 // indirect
github.com/yeya24/promlinter v0.2.0 // indirect
github.com/ykadowak/zerologlint v0.1.3 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
gitlab.com/bosi/decorder v0.4.1 // indirect
go-simpler.org/sloglint v0.1.2 // indirect
go.opencensus.io v0.24.0 // indirect
Expand Down Expand Up @@ -274,7 +295,6 @@ require (
google.golang.org/genproto v0.0.0-20231211222908-989df2bf70f3 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231211222908-989df2bf70f3 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
google.golang.org/grpc v1.60.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit 32a35f1

Please sign in to comment.