From 96cc755f35137bb7d84b23798f7165e757e9bad1 Mon Sep 17 00:00:00 2001 From: s0s01qp Date: Mon, 19 Jul 2021 10:12:00 +0530 Subject: [PATCH] updated go mod file and added test cases --- core/env_test.go | 18 ++++++++++++++++++ core/httpTrace_test.go | 1 + flags/flags.go | 2 +- go.mod | 25 ++----------------------- go.sum | 7 ++++++- 5 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 core/env_test.go create mode 100644 core/httpTrace_test.go diff --git a/core/env_test.go b/core/env_test.go new file mode 100644 index 0000000..e9c3910 --- /dev/null +++ b/core/env_test.go @@ -0,0 +1,18 @@ +package core_test + +import ( + "github.com/sinhashubham95/go-actuator/commons" + "github.com/sinhashubham95/go-actuator/core" + "github.com/stretchr/testify/assert" + "os" + "testing" +) + +func TestGetEnvironmentVariables(t *testing.T) { + _ = os.Setenv("key1", "value1") + _ = os.Setenv("key2", "value2") + environ := core.GetEnvironmentVariables() + assert.Equal(t, "value1", environ["key1"]) + assert.Equal(t, "value2", environ["key2"]) + assert.Equal(t, commons.EnvDefaultValue, environ[commons.Env]) +} diff --git a/core/httpTrace_test.go b/core/httpTrace_test.go new file mode 100644 index 0000000..aa581d3 --- /dev/null +++ b/core/httpTrace_test.go @@ -0,0 +1 @@ +package core_test diff --git a/flags/flags.go b/flags/flags.go index eebe991..782ffe6 100644 --- a/flags/flags.go +++ b/flags/flags.go @@ -1,8 +1,8 @@ package flags import ( - "flag" "github.com/sinhashubham95/go-actuator/commons" + flag "github.com/spf13/pflag" ) var ( diff --git a/go.mod b/go.mod index 0f04c97..8f1ce79 100644 --- a/go.mod +++ b/go.mod @@ -4,28 +4,7 @@ go 1.16 require ( github.com/gin-gonic/gin v1.7.2 - github.com/stretchr/testify v1.4.0 + github.com/spf13/pflag v1.0.5 + github.com/stretchr/testify v1.7.0 github.com/valyala/fasthttp v1.28.0 ) - -require ( - github.com/andybalholm/brotli v1.0.2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-playground/locales v0.13.0 // indirect - github.com/go-playground/universal-translator v0.17.0 // indirect - github.com/go-playground/validator/v10 v10.4.1 // indirect - github.com/golang/protobuf v1.3.3 // indirect - github.com/json-iterator/go v1.1.9 // indirect - github.com/klauspost/compress v1.12.2 // indirect - github.com/leodido/go-urn v1.2.0 // indirect - github.com/mattn/go-isatty v0.0.12 // indirect - github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect - github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/ugorji/go/codec v1.1.7 // indirect - github.com/valyala/bytebufferpool v1.0.0 // indirect - golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect - golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect - gopkg.in/yaml.v2 v2.2.8 // indirect -) diff --git a/go.sum b/go.sum index 7dd7158..5345fa9 100644 --- a/go.sum +++ b/go.sum @@ -33,10 +33,13 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLD github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= @@ -71,3 +74,5 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=