-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Document testing practices #169
Comments
Maybe not the best solution but one pattern we currently use in our company: We have a Here's our Makefile stanza if that's of any help # Copyright © Loft Orbital Solutions Inc.
project_name := project
timoni := timoni
cue := cue
go := go
dyff := dyff
# Define sources
GEN_DEPS := $(shell go list -f '{{ join .Imports " " }}')
GEN_DEPS_DIR := $(addsuffix /.generated,$(addprefix cue.mod/gen/,$(GEN_DEPS)))
SOURCES := $(wildcard *.cue) $(wildcard templates/*.cue)
TEST_FILES := $(wildcard test/*.cue)
TEST_TARGETS := $(patsubst test/%.cue,test/.%.run,$(TEST_FILES))
all: lint test fmt ## Run all checks and format code
go.sum: dependencies.go go.mod
$(go) mod tidy
$(GEN_DEPS_DIR): go.sum
$(cue) get go $(patsubst %/.generated,%,$(patsubst cue.mod/gen/%,%,$@))
@touch $@
init: $(GEN_DEPS_DIR) ## Initialize module
lint: init ## Check module for syntax errors
$(timoni) mod lint .
.PHONY: lint
test/.%.actual.yml: test/%.cue $(SOURCES) init
$(timoni) build -n default -f $< $(project_name) . > $@
$(TEST_TARGETS): test/.%.run: test/%.expected.yml test/.%.actual.yml
$(dyff) between -is $^
@touch $@
test: $(TEST_TARGETS) ## Run tests
fmt: ## Format CUE files
$(cue) fmt ./...
.PHONY: fmt
help: ## Show help
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help
.DEFAULT_GOAL := help Btw regarding the Here's an example of that package main
// Placeholder for cue get go generation dependencies
import (
_ "k8s.io/api/apps/v1"
_ "k8s.io/api/core/v1"
_ "k8s.io/api/autoscaling/v2"
_ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/sql/v1beta1"
_ "github.com/GoogleCloudPlatform/k8s-config-connector/pkg/clients/generated/apis/iam/v1beta1"
) |
The
podinfo
example provided here has some test files.Documentation around this would be great!
The text was updated successfully, but these errors were encountered: