Skip to content

Commit

Permalink
feat: add more test case kit and update task of make ci*
Browse files Browse the repository at this point in the history
  • Loading branch information
sinlov committed Feb 6, 2024
1 parent d3d8df6 commit b3582ba
Show file tree
Hide file tree
Showing 8 changed files with 391 additions and 292 deletions.
21 changes: 15 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ ROOT_NAME?=temp-golang-cli-fast

## MakeDocker.mk settings start
ROOT_OWNER ?=bridgewwater
ROOT_PARENT_SWITCH_TAG=1.19.13
ROOT_PARENT_SWITCH_TAG =1.19.13
# for image local build
INFO_TEST_BUILD_DOCKER_PARENT_IMAGE=golang
INFO_TEST_BUILD_DOCKER_PARENT_IMAGE =golang
# for image running
INFO_BUILD_DOCKER_FROM_IMAGE=alpine:3.17
INFO_BUILD_DOCKER_FILE=Dockerfile
INFO_TEST_BUILD_DOCKER_FILE=Dockerfile.s6
INFO_BUILD_DOCKER_FROM_IMAGE =alpine:3.17
INFO_BUILD_DOCKER_FILE =Dockerfile
INFO_TEST_BUILD_DOCKER_FILE =Dockerfile.s6
## MakeDocker.mk settings end

## run info start
Expand Down Expand Up @@ -133,6 +133,12 @@ style: modTidy modVerify modFmt modLintRun

ci: modTidy modVerify modFmt modVet modLintRun test

ciTestBenchmark: modTidy modVerify testBenchmark

ciCoverageShow: modTidy modVerify modVet testCoverage testCoverageShow

ciAll: ci ciTestBenchmark ciCoverageShow

buildMain:
@echo "-> start build local OS: ${PLATFORM} ${OS_BIT}"
ifeq ($(OS),Windows_NT)
Expand Down Expand Up @@ -232,8 +238,11 @@ endif
@echo "~> make testCoverageBrowser - see coverage at browser --invert-match by config"
@echo "~> make testBenchmark - run go test benchmark case all"
@echo "~> make ci - run CI tools tasks"
@echo "~> make ciTestBenchmark - run CI tasks as test benchmark"
@echo "~> make ciCoverageShow - run CI tasks as test coverage and show"
@echo "~> make ciAll - run CI tasks all"
@echo "~> make style - run local code fmt and style check"
@echo "~> make devHelp - run as develop mode show help"
@echo "~> make devHelp - run as develop mode see help with ${ENV_RUN_INFO_HELP_ARGS}"
@echo "~> make dev - run as develop mode"
ifeq ($(OS),Windows_NT)
@echo "~> make devInstallLocal - install at $(subst /,\,${ENV_GO_PATH}/bin)"
Expand Down
38 changes: 38 additions & 0 deletions command_test/env_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package command_test

import (
"github.com/stretchr/testify/assert"
"testing"
)

func TestEnvKeys(t *testing.T) {
// mock EnvKeys
const keyEnvs = "ENV_KEYS"
t.Logf("~> mock EnvKeys")

setEnvBool(t, keyEnvDebug, true)

setEnvInt64(t, keyEnvCiNum, 2)

setEnvStr(t, keyEnvCiKey, "foo")

// do EnvKeys
t.Logf("~> do EnvKeys")

// verify EnvKeys

assert.True(t, fetchOsEnvBool(keyEnvDebug, false))
assert.Equal(t, 2, fetchOsEnvInt(keyEnvCiNum, 0))
assert.Equal(t, "foo", fetchOsEnvStr(keyEnvCiKey, ""))
envArray := fetchOsEnvArray(keyEnvs)
assert.Nil(t, envArray)

setEnvStr(t, keyEnvs, "foo, bar,My ")

envArray = fetchOsEnvArray(keyEnvs)

assert.NotNil(t, envArray)
assert.Equal(t, "foo", envArray[0])
assert.Equal(t, "bar", envArray[1])
assert.Equal(t, "My", envArray[2])
}
Loading

0 comments on commit b3582ba

Please sign in to comment.