Start adding tests
This commit is contained in:
14
Makefile
14
Makefile
@ -8,17 +8,18 @@ MAPPER_GEN_FILE := ./api/eiaapi_funcmap.gen.go
|
||||
GO_FORMATTER := gofumpt
|
||||
|
||||
IS_GNU_SED := $(shell sed --version >/dev/null 2>&1 && echo true || echo false)
|
||||
SED_INLINE := $(if $(IS_GNU_SED),-i '',-i)
|
||||
SED_INLINE := $(if $(IS_GNU_SED),-i,-i '')
|
||||
|
||||
.PHONY: all schema generate build install clean
|
||||
.PHONY: all schema generate test build install clean
|
||||
|
||||
# Default target
|
||||
all: schema generate build install
|
||||
all: schema generate test build install
|
||||
|
||||
# Retrieve and prepare schema
|
||||
schema:
|
||||
curl https://www.eia.gov/opendata/$(SCHEMA_ZIP) -o $(SCHEMA_DIR)/$(SCHEMA_ZIP)
|
||||
unzip -o $(SCHEMA_DIR)/$(SCHEMA_ZIP) -d $(SCHEMA_DIR)
|
||||
@echo "Using GNU sed: $(IS_GNU_SED)"
|
||||
sed -E $(SED_INLINE) 's/responses\/data/schemas\/DataResponseContainer/g' $(SCHEMA_DIR)/$(SCHEMA_YML)
|
||||
sed -E $(SED_INLINE) 's/responses\/route/schemas\/RouteResponse/g' $(SCHEMA_DIR)/$(SCHEMA_YML)
|
||||
sed -E $(SED_INLINE) 's/responses\/facets/schemas\/FacetOptionListContainer/g' $(SCHEMA_DIR)/$(SCHEMA_YML)
|
||||
@ -30,6 +31,7 @@ schema:
|
||||
# Generate code
|
||||
generate:
|
||||
go generate ./...
|
||||
@echo "Using GNU sed: $(IS_GNU_SED)"
|
||||
sed -E $(SED_INLINE) 's/Total[[:space:]]+\*int/Total *string/g' $(CLIENT_GEN_FILE)
|
||||
sed -E $(SED_INLINE) 's/Command[[:space:]]+\*\[\]string/Command *string/g' $(CLIENT_GEN_FILE)
|
||||
sed -E $(SED_INLINE) 's/Routes[[:space:]]+\*\[\]string/Routes *[]Routes/g' $(CLIENT_GEN_FILE)
|
||||
@ -37,8 +39,12 @@ generate:
|
||||
$(GO_FORMATTER) -w $(CLIENT_GEN_FILE)
|
||||
$(GO_FORMATTER) -w $(MAPPER_GEN_FILE)
|
||||
|
||||
test:
|
||||
# Test EIA API client package
|
||||
go test -v ./pkg/eia
|
||||
|
||||
# Build the client command binary
|
||||
build: generate
|
||||
build: generate test
|
||||
go build -o bin/eia-client $(CLIENT_PKG)
|
||||
|
||||
# Install the client command binary
|
||||
|
Reference in New Issue
Block a user