Jordan Jensen 3575299373 Add unit tests to airshipui plugin
- Remove globbed url route
- Create unit tests for register.go
- Add test and coverage-html targets to Makefile
- Add test coverage output to gitignore

Change-Id: I980e28204afc83b67a8a4d2d6af500caa9e530c2
2019-12-13 18:47:29 +00:00

56 lines
1.3 KiB
Makefile

# Copyright (c) 2019 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
SHELL=/bin/bash
# Obtain the version and git commit info
GIT_VERSION=$(shell git describe --match 'v*' --always)
# Override the value of the version variable in main.go
LD_FLAGS= '-X main.version=$(GIT_VERSION)'
GO_FLAGS= -ldflags=$(LD_FLAGS)
PLUGINS:= $(shell ls cmd)
ifdef XDG_CONFIG_HOME
OCTANT_PLUGINSTUB_DIR ?= ${XDG_CONFIG_HOME}/octant/plugins
# Determine in on windows
else ifeq ($(OS),Windows_NT)
OCTANT_PLUGINSTUB_DIR ?= ${LOCALAPPDATA}/octant/plugins
else
OCTANT_PLUGINSTUB_DIR ?= ${HOME}/.config/octant/plugins
endif
DIRS = internal
RECURSIVE_DIRS = $(addprefix ./, $(addsuffix /..., $(DIRS)))
.PHONY: install-plugins
install-plugins: $(PLUGINS)
$(PLUGINS):
mkdir -p $(OCTANT_PLUGINSTUB_DIR)
go build -o $(OCTANT_PLUGINSTUB_DIR)/$@-plugin $(GO_FLAGS) opendev.org/airship/airshipui/cmd/$@
.PHONY: test
test: generate
go test $(RECURSIVE_DIRS) -v -coverprofile=coverage.out
.PHONY: coverage-html
coverage-html: test
go tool cover -html=coverage.out
.PHONY: vet
vet:
go vet $(RECURSIVE_DIRS)
.PHONY: generate
generate:
go generate -v $(RECURSIVE_DIRS)
.PHONY: clean
clean:
git clean -dx $(DIRS)
.PHONY: ci
ci: test vet
# The golang-unit zuul job calls the env target, so create one
.PHONY: env