Skip to content

Commit

Permalink
Merge pull request #65 from cybozu-go/fix-20231116
Browse files Browse the repository at this point in the history
Refactor test
  • Loading branch information
masa213f authored Nov 16, 2023
2 parents ea9df44 + dcba72b commit 7a65d77
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- run: docker run -d --network host quay.io/coreos/etcd:v3.5.10
- run: make setup
- run: make check-generate
- run: make test
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# Makefile for etcdutil

## Dependency versions
ETCD_VER=v3.5.10

ETCD_VER=$(shell go list -m -f '{{.Version}}' go.etcd.io/etcd/client/v3)
SUDO=sudo

.PHONY: all
all:
echo $(ETCD_VER)
@echo "Specify one of these targets:"
@echo
@echo " test - run single host tests."
@echo " setup - install dependencies."

.PHONY: test
test:
test -z "$(gofmt -s -d . | tee /dev/stderr)"
staticcheck .
go build ./...
go test -race -v ./...
Expand Down
16 changes: 1 addition & 15 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ const (
)

func testMain(m *testing.M) int {
ci := os.Getenv("CI") == "true"
if ci {
code := m.Run()
os.Exit(code)
}

etcdPath, err := os.MkdirTemp("", "etcdutil-test")
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -53,16 +47,8 @@ func TestMain(m *testing.M) {
func testEtcdClient(t *testing.T) {
t.Parallel()

var clientURL string
ci := os.Getenv("CI") == "true"
if ci {
clientURL = "http://localhost:2379"
} else {
clientURL = etcdClientURL
}

cfg := NewConfig(t.Name() + "/")
cfg.Endpoints = []string{clientURL}
cfg.Endpoints = []string{etcdClientURL}
_, err := NewClient(cfg)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 7a65d77

Please sign in to comment.