Skip to content

Commit

Permalink
Unit tests: fix authentication to localstack
Browse files Browse the repository at this point in the history
  • Loading branch information
mmetc committed Mar 8, 2023
1 parent c7014db commit 01f7f2e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ env:
AWS_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
AWS_REGION: us-east-1
# and to override our endpoint in aws sdk
AWS_ENDPOINT_FORCE: http://localhost:4566
KINESIS_INITIALIZE_STREAMS: "stream-1-shard:1,stream-2-shards:2"
CROWDSEC_FEATURE_DISABLE_HTTP_RETRY_BACKOFF: true

Expand Down Expand Up @@ -142,9 +140,7 @@ jobs:
go install github.com/kyoh86/richgo@v0.3.10
set -o pipefail
make build
go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models \
| sed 's/ *coverage:.*of statements in.*//' \
| richgo testfilter
make go-acc | richgo testfilter
- name: Build and run tests (static)
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Test binaries, built from *_test.go
pkg/csplugin/tests/cs_plugin_test*

# Output of the go coverage tool, specifically when used with LiteIDE
# Output of go-acc
*.out

# Development artifacts, backups, etc
Expand Down
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,22 @@ testclean: bats-clean
@$(RM) pkg/cwhub/install $(WIN_IGNORE_ERR)
@$(RM) pkg/types/example.txt $(WIN_IGNORE_ERR)

.PHONY: test
test: export AWS_ENDPOINT_FORCE=http://localhost:4566
test: goversion
export AWS_ENDPOINT_FORCE=http://localhost:4566
export AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
export AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

testenv:
@echo 'NOTE: You need Docker, docker-compose and run "make localstack" in a separate shell ("make localstack-stop" to terminate it)'

.PHONY: test
test: testenv goversion
$(GOTEST) $(LD_OPTS) ./...

.PHONY: go-acc
go-acc: testenv goversion
go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models -- $(LD_OPTS) | \
sed 's/ *coverage:.*of statements in.*//'

.PHONY: localstack
localstack:
docker-compose -f test/localstack/docker-compose.yml up
Expand Down
1 change: 0 additions & 1 deletion test/localstack/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ services:
AWS_ACCESS_KEY_ID: "AKIAIOSFODNN7EXAMPLE"
AWS_SECRET_ACCESS_KEY: "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
AWS_REGION: "us-east-1"
AWS_ENDPOINT_FORCE: "http://localhost:4566"

volumes:
- "${TMPDIR:-/tmp}/localstack:/var/lib/localstack"
Expand Down

0 comments on commit 01f7f2e

Please sign in to comment.