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

Refactor test #65

Merged
merged 1 commit into from
Nov 16, 2023
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
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