From 0a589a256523b8f59805d5858d6e6015bc702937 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Sat, 29 Jan 2022 13:29:09 +0100 Subject: [PATCH] add test --- .gitignore | 2 ++ .hooks/pre-commit | 4 ++-- tests/build.sh | 22 ++++++++++++++++++++++ tests/main.go | 13 +++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100755 tests/build.sh create mode 100644 tests/main.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..995126c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +tests/buildenv/* +tests/bin/* diff --git a/.hooks/pre-commit b/.hooks/pre-commit index 24df17c..37332a9 100755 --- a/.hooks/pre-commit +++ b/.hooks/pre-commit @@ -1,3 +1,3 @@ #!/usr/bin/env bash -go fmt *.go -git add *.go +go fmt *.go tests/*.go +git add *.go tests/*.go diff --git a/tests/build.sh b/tests/build.sh new file mode 100755 index 0000000..a6992ed --- /dev/null +++ b/tests/build.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +dir=$(dirname $(realpath $0)) +export GO111MODULE=on +export GOPROXY=direct +export GOPATH=${dir}/buildenv/deps + +mkdir -p ${dir}/buildenv +chmod -R 755 ${dir}/buildenv +rm -rf ${dir}/buildenv + +mkdir -p "${dir}/buildenv/src" +mkdir -p ${GOPATH}/src +mkdir -p ${dir}/bin + +cp -r "${dir}/main.go" "${dir}/buildenv/src/main.go" + +cd ${dir}/buildenv + +go mod init src +go mod tidy + +go build -o "${dir}/bin/test" "src/main.go" diff --git a/tests/main.go b/tests/main.go new file mode 100644 index 0000000..349f9a5 --- /dev/null +++ b/tests/main.go @@ -0,0 +1,13 @@ +package main + +import ("git.purser.it/roypur/envconf" + "fmt") + +func main() { + conf := envconf.NewConfig() + conf.Define("this_is_a_map", envconf.FixedHex(22)) + conf.Parse() + conf.Status() + + fmt.Println(conf.GetHex("this_is_a_map")) +}