From c27154c73cf371f41810649ff812aa3afcf654dc Mon Sep 17 00:00:00 2001 From: "alexey.makhonin" Date: Fri, 21 Jul 2023 16:17:10 +0300 Subject: [PATCH] Add tests workflow Signed-off-by: alexey.makhonin --- .github/workflows/tests.yml | 25 +++++++++++++++++++++ Makefile | 3 +-- pkg/master_resolver/master_resolver_test.go | 6 ++--- 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..a1ddf47 --- /dev/null +++ b/.github/workflows/tests.yml @@ -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: go test -v -race -cover ./... diff --git a/Makefile b/Makefile index 6022ae3..a8e5f14 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/pkg/master_resolver/master_resolver_test.go b/pkg/master_resolver/master_resolver_test.go index 8ac4a57..391200c 100644 --- a/pkg/master_resolver/master_resolver_test.go +++ b/pkg/master_resolver/master_resolver_test.go @@ -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 @@ -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", }, },