Skip to content

Commit

Permalink
Add tests workflow
Browse files Browse the repository at this point in the history
Signed-off-by: alexey.makhonin <[email protected]>
  • Loading branch information
alexey.makhonin committed Jul 21, 2023
1 parent 118d5fb commit 87f5e8b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Tests

on:
push:
branches:
- master

pull_request_target:
branches:
- master

jobs:
tests:
runs-on: ubuntu-latest
container: ubuntu
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: "1.20"

- name: Run tests
run: CGO_ENABLED=1 go test -v -race -cover ./...
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ GOARCH ?= $(shell go env GOARCH)
CGO_ENABLED ?= 0

.PHONY: test
test:
go test -v ./...
tests-intergration:
cd test && ./test.sh

.PHONY: build
Expand Down
6 changes: 3 additions & 3 deletions pkg/master_resolver/master_resolver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func Test_redisMasterFromSentinelAddr(t *testing.T) {
masterName string
}

mockServerAddr := &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 12700}
mockServerAddr := &net.TCPAddr{IP: net.IPv4(0, 0, 0, 0), Port: 12700}
tests := []struct {
name string
args args
Expand All @@ -25,9 +25,9 @@ func Test_redisMasterFromSentinelAddr(t *testing.T) {
}{
{
name: "all is ok",
want: &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 12700},
want: mockServerAddr,
args: args{
sentinelAddress: mockServerAddr,
sentinelAddress: &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 12700},
masterName: "test-master",
},
},
Expand Down

0 comments on commit 87f5e8b

Please sign in to comment.