Skip to content

Commit 7a65d77

Browse files
authored
Merge pull request #65 from cybozu-go/fix-20231116
Refactor test
2 parents ea9df44 + dcba72b commit 7a65d77

File tree

3 files changed

+3
-20
lines changed

3 files changed

+3
-20
lines changed

.github/workflows/main.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
- uses: actions/setup-go@v4
1414
with:
1515
go-version-file: go.mod
16-
- run: docker run -d --network host quay.io/coreos/etcd:v3.5.10
1716
- run: make setup
1817
- run: make check-generate
1918
- run: make test

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
# Makefile for etcdutil
22

3-
## Dependency versions
4-
ETCD_VER=v3.5.10
5-
3+
ETCD_VER=$(shell go list -m -f '{{.Version}}' go.etcd.io/etcd/client/v3)
64
SUDO=sudo
75

86
.PHONY: all
97
all:
8+
echo $(ETCD_VER)
109
@echo "Specify one of these targets:"
1110
@echo
1211
@echo " test - run single host tests."
1312
@echo " setup - install dependencies."
1413

1514
.PHONY: test
1615
test:
17-
test -z "$(gofmt -s -d . | tee /dev/stderr)"
1816
staticcheck .
1917
go build ./...
2018
go test -race -v ./...

client_test.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ const (
1313
)
1414

1515
func testMain(m *testing.M) int {
16-
ci := os.Getenv("CI") == "true"
17-
if ci {
18-
code := m.Run()
19-
os.Exit(code)
20-
}
21-
2216
etcdPath, err := os.MkdirTemp("", "etcdutil-test")
2317
if err != nil {
2418
log.Fatal(err)
@@ -53,16 +47,8 @@ func TestMain(m *testing.M) {
5347
func testEtcdClient(t *testing.T) {
5448
t.Parallel()
5549

56-
var clientURL string
57-
ci := os.Getenv("CI") == "true"
58-
if ci {
59-
clientURL = "http://localhost:2379"
60-
} else {
61-
clientURL = etcdClientURL
62-
}
63-
6450
cfg := NewConfig(t.Name() + "/")
65-
cfg.Endpoints = []string{clientURL}
51+
cfg.Endpoints = []string{etcdClientURL}
6652
_, err := NewClient(cfg)
6753
if err != nil {
6854
t.Fatal(err)

0 commit comments

Comments
 (0)