Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: fix multi module test #78

Merged
merged 4 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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