fix: implement repository test
changes: - Implement repository test for the sqlite backend - Add testutils package to start container images - Remove deprecated till_date in measured values - Renamed columns of the table humidities, pressures and temperatures
This commit is contained in:
146
Makefile
146
Makefile
@ -1,6 +1,7 @@
|
||||
# VERSION/RELEASE
|
||||
# If no version is specified as a parameter of make, the last git hash
|
||||
# value is taken.
|
||||
EPOCH=0
|
||||
VERSION?=$(shell git describe --abbrev=0)+$(shell date +'%Y%m%d%H%I%S')
|
||||
RELEASE?=1
|
||||
|
||||
@ -12,55 +13,6 @@ RELEASE?=1
|
||||
GOPROXY?=$(shell go env GOPROXY)
|
||||
GOPRIVATE?=$(shell go env GOPRIVATE)
|
||||
|
||||
# EXECUTABLE
|
||||
# Executable binary which should be compiled for different architecures
|
||||
EXECUTABLE:=flucky
|
||||
|
||||
# DARWIN_EXECUTABLES AND TARGETS
|
||||
DARWIN_EXECUTABLES:=\
|
||||
darwin/386/${EXECUTABLE} \
|
||||
darwin/amd64/${EXECUTABLE}
|
||||
|
||||
DARWIN_EXECUTABLE_TARGETS:=\
|
||||
${DARWIN_EXECUTABLES:%=bin/%}
|
||||
|
||||
# FREEBSD_EXECUTABLES AND TARGETS
|
||||
FREEBSD_EXECUTABLES:=\
|
||||
freebsd/amd64/${EXECUTABLE}
|
||||
|
||||
FREEBSD_EXECUTABLE_TARGETS:=\
|
||||
${FREEBSD_EXECUTABLES:%=bin/%}
|
||||
|
||||
# LINUX_EXECUTABLES AND TARGETS
|
||||
LINUX_EXECUTABLES:=\
|
||||
linux/amd64/${EXECUTABLE} \
|
||||
linux/386/${EXECUTABLE} \
|
||||
linux/arm/5/${EXECUTABLE} \
|
||||
linux/arm/7/${EXECUTABLE}
|
||||
|
||||
LINUX_EXECUTABLE_TARGETS:=\
|
||||
${LINUX_EXECUTABLES:%=bin/%}
|
||||
|
||||
# UNIX_EXECUTABLES AND TARGETS
|
||||
# Define all executables for different architectures and operation systems
|
||||
UNIX_EXECUTABLES:= \
|
||||
${DARWIN_EXECUTABLES} \
|
||||
${FREEBSD_EXECUTABLES} \
|
||||
${LINUX_EXECUTABLES}
|
||||
|
||||
UNIX_EXECUTABLE_TARGETS:= \
|
||||
${DARWIN_EXECUTABLE_TARGETS} \
|
||||
${FREEBSD_EXECUTABLE_TARGETS} \
|
||||
${LINUX_EXECUTABLE_TARGETS}
|
||||
|
||||
# EXECUTABLES AND TARGETS
|
||||
# Include all UNIX and Windows targets.
|
||||
EXECUTABLES:=\
|
||||
${UNIX_EXECUTABLES}
|
||||
|
||||
EXECUTABLE_TARGETS:= \
|
||||
${UNIX_EXECUTABLE_TARGETS}
|
||||
|
||||
# CONTAINER_RUNTIME
|
||||
# The CONTAINER_RUNTIME variable will be used to specified the path to a
|
||||
# container runtime. This is needed to start and run a container images.
|
||||
@ -96,48 +48,15 @@ CONTAINER_IMAGE_SHORT=${CONTAINER_IMAGE_NAMESPACE}/${CONTAINER_IMAGE_NAME}:${CON
|
||||
|
||||
# BINARIES
|
||||
# ==============================================================================
|
||||
# current os
|
||||
EXECUTABLE=flucky
|
||||
EXECUTABLE_TARGETS:= \
|
||||
bin/linux/amd64/${EXECUTABLE} \
|
||||
bin/linux/arm/5/${EXECUTABLE} \
|
||||
bin/linux/arm/7/${EXECUTABLE} \
|
||||
bin/tmp/${EXECUTABLE}
|
||||
|
||||
${EXECUTABLE}: bin/tmp/${EXECUTABLE}
|
||||
|
||||
# build all binaries
|
||||
PHONY:=all
|
||||
all: ${EXECUTABLE_TARGETS}
|
||||
|
||||
# darwin os
|
||||
bin/darwin/386/${EXECUTABLE}: bindata
|
||||
CGO_ENABLED=1 \
|
||||
GOOS=darwin \
|
||||
GOARCH=386 \
|
||||
GOPROXY=${GOPROXY} \
|
||||
GOPRIVATE=${GOPRIVATE} \
|
||||
go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@}
|
||||
|
||||
bin/darwin/amd64/${EXECUTABLE}: bindata
|
||||
CGO_ENABLED=1 \
|
||||
GOOS=darwin \
|
||||
GOARCH=amd64 \
|
||||
GOPROXY=${GOPROXY} \
|
||||
GOPRIVATE=${GOPRIVATE} \
|
||||
go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@}
|
||||
|
||||
# freebsd os
|
||||
bin/freebsd/amd64/${EXECUTABLE}: bindata
|
||||
CGO_ENABLED=1 \
|
||||
GOOS=freebsd \
|
||||
GOARCH=amd64 \
|
||||
GOPROXY=${GOPROXY} \
|
||||
GOPRIVATE=${GOPRIVATE} \
|
||||
go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@}
|
||||
|
||||
# linux os
|
||||
bin/linux/386/${EXECUTABLE}: bindata
|
||||
CGO_ENABLED=1 \
|
||||
GOOS=linux \
|
||||
GOARCH=386 \
|
||||
GOPROXY=${GOPROXY} \
|
||||
GOPRIVATE=${GOPRIVATE} \
|
||||
go build -ldflags "-X main.version=${VERSION:v%=%}" -o ${@}
|
||||
|
||||
bin/linux/amd64/${EXECUTABLE}: bindata
|
||||
CGO_ENABLED=1 \
|
||||
GOOS=linux \
|
||||
@ -181,31 +100,26 @@ bindata: clean ${BINDATA_TARGETS}
|
||||
pkg/repository/db/bindataSQL.go:
|
||||
go-bindata -pkg db -o ./pkg/repository/db/bindataSQL.go pkg/repository/db/postgres/*** pkg/repository/db/sqlite3/***
|
||||
|
||||
# TEST
|
||||
# ==============================================================================
|
||||
PHONY+=test/unit
|
||||
test/unit: clean bindata
|
||||
go test -v -race -coverprofile=coverage.txt -covermode=atomic $(shell go list ./... | grep -v db)
|
||||
|
||||
# PACKAGES
|
||||
# ==============================================================================
|
||||
%.rpm: %
|
||||
rpm-builder \
|
||||
--exec-file "$<:/usr/bin/${EXECUTABLE}" \
|
||||
--dir "systemd:/usr/lib/systemd/system" \
|
||||
--license "Apache 2.0" \
|
||||
--version ${VERSION:v%=%} \
|
||||
--release ${RELEASE} \
|
||||
--out ${@} \
|
||||
${EXECUTABLE}
|
||||
|
||||
# OTHER STUFF
|
||||
# CLEAN
|
||||
# ==============================================================================
|
||||
PHONY+=clean
|
||||
clean:
|
||||
rm --force ${BINDATA_TARGETS} || true
|
||||
rm --force --recursive bin/ || true
|
||||
|
||||
# TEST
|
||||
# ==============================================================================
|
||||
PHONY+=test/unit
|
||||
test/unit: bindata
|
||||
go test -v -race -coverprofile=coverage.txt -covermode=atomic -timeout 600s -count=1 ./pkg/...
|
||||
|
||||
PHONY+=test/integration
|
||||
test/integration:
|
||||
go test -v -count=1 -timeout 600s ./it/...
|
||||
|
||||
test/coverage: test/unit
|
||||
go tool cover -html=coverage.txt
|
||||
|
||||
# CONTAINER IMAGE STEPS
|
||||
# ==============================================================================
|
||||
PHONY+=container-image/build/amd64
|
||||
@ -243,8 +157,8 @@ PHONY+=container-run/all
|
||||
container-run/all:
|
||||
$(MAKE) container-run COMMAND=${@:container-run/%=%}
|
||||
|
||||
PHONY+=${UNIX_EXECUTABLE_TARGETS:%=container-run/%}
|
||||
${UNIX_EXECUTABLE_TARGETS:%=container-run/%}:
|
||||
PHONY+=${EXECUTABLE_TARGETS:%=container-run/%}
|
||||
${EXECUTABLE_TARGETS:%=container-run/%}:
|
||||
$(MAKE) container-run COMMAND=${@:container-run/%=%}
|
||||
|
||||
# CONTAINER STEPS - GO-BINDATA
|
||||
@ -253,18 +167,18 @@ PHONY+=container-run/bindata
|
||||
container-run/bindata:
|
||||
$(MAKE) container-run COMMAND=${@:container-run/%=%}
|
||||
|
||||
# CONTAINER STEPS - CLEAN
|
||||
# ==============================================================================
|
||||
PHONY+=container-run/clean
|
||||
container-run/clean:
|
||||
$(MAKE) container-run COMMAND=${@:container-run/%=%}
|
||||
|
||||
# CONTAINER STEPS - TEST
|
||||
# ==============================================================================
|
||||
PHONY+=container-run/test/unit
|
||||
container-run/test/unit:
|
||||
$(MAKE) container-run COMMAND=${@:container-run/%=%}
|
||||
|
||||
# CONTAINER STEPS - OTHER STUF
|
||||
# ==============================================================================
|
||||
PHONY+=container-run/clean
|
||||
container-run/clean:
|
||||
$(MAKE) container-run COMMAND=${@:container-run/%=%}
|
||||
|
||||
# GENERAL CONTAINER COMMAND
|
||||
# ==============================================================================
|
||||
PHONY+=container-run
|
||||
|
Reference in New Issue
Block a user