Skip to content

Commit

Permalink
*: fix multi module test (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhebox authored Sep 9, 2022
1 parent 06effc0 commit b1853c4
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ jobs:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- if: ${{ runner.os == 'Windows' }}
name: Use GNU tar for faster cache restore
shell: cmd
run: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
- name: "checkout repo"
uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ test
vendor
work
.vscode/
.coverage*
.cover*
17 changes: 11 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,24 @@ default: cmd

cmd: $(EXECUTABLE_TARGETS)

build:
build: cmd
go build $(BUILDFLAGS) ./...
cd lib && go build $(BUILDFLAGS) ./...

cmd_%: OUTPUT=$(patsubst cmd_%,./bin/%,$@)
cmd_%: SOURCE=$(patsubst cmd_%,./cmd/%,$@)
cmd_%:
go build $(BUILDFLAGS) -o $(OUTPUT) $(SOURCE)

test:
go test -coverprofile=.coverage.out ./...
go tool cover -func=.coverage.out -o .coverage.func
tail -1 .coverage.func
go tool cover -html=.coverage.out -o .coverage.html
test: ./bin/gocovmerge
go test -coverprofile=.cover.pkg ./...
cd lib && go test -coverprofile=../.cover.lib ./...
./bin/gocovmerge .cover.* > .cover
rm .cover.*
go tool cover -html=.cover -o .cover.html

./bin/gocovmerge:
GOBIN=$(GOBIN) go install github.com/wadey/gocovmerge@master

docker:
docker build $(DOCKERFLAG) -t "tiproxy:${IMAGE_TAG}" --build-arg='GOPROXY=$(shell go env GOPROXY),BUILDFLAGS=$(BUILDFLAGS),' -f docker/Dockerfile .
14 changes: 14 additions & 0 deletions lib/config/namespace_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package config

import (
Expand Down
32 changes: 19 additions & 13 deletions lib/config/proxy_test.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package config

import (
"net/url"
"testing"

"github.com/stretchr/testify/require"
)

var testProxyConfig = Config{
Workdir: "./wd",
LCUrlsI: []string{"http://0.0.0.0:3080"},
ACUrlsI: []string{},
LPUrlsI: []string{"http://0.0.0.0:3081"},
APUrlsI: []string{},
LCUrls: []url.URL{},
ACUrls: []url.URL{},
LPUrls: []url.URL{},
APUrls: []url.URL{},
Config: ConfigManager{
Advance: Advance{
PeerPort: "343",
IgnoreWrongNamespace: true,
WatchInterval: "30m",
},
Proxy: ProxyServer{
Addr: "0.0.0.0:4000",
Expand All @@ -29,13 +36,12 @@ var testProxyConfig = Config{
},
},
API: API{
Addr: "0.0.0.0:3080",
EnableBasicAuth: false,
User: "user",
Password: "pwd",
},
Metrics: Metrics{
PromCluster: "ffgfg",
},
Metrics: Metrics{},
Log: Log{
Level: "info",
Encoder: "tidb",
Expand Down

0 comments on commit b1853c4

Please sign in to comment.