From ec260bfbfcccfd466ec8ffdd51a8a55beb7c803a Mon Sep 17 00:00:00 2001 From: s0s01qp Date: Sun, 18 Jul 2021 21:15:57 +0530 Subject: [PATCH] added test cases --- commons/utils_test.go | 17 +++++++++++++++++ go.mod | 3 +++ 2 files changed, 20 insertions(+) create mode 100644 commons/utils_test.go diff --git a/commons/utils_test.go b/commons/utils_test.go new file mode 100644 index 0000000..e232935 --- /dev/null +++ b/commons/utils_test.go @@ -0,0 +1,17 @@ +package commons_test + +import ( + "github.com/stretchr/testify/assert" + "testing" + + "github.com/sinhashubham95/go-actuator/commons" +) + +func TestEncodeJSON(t *testing.T) { + data := map[string]string{ + "naruto": "rocks", + } + bytes, err := commons.EncodeJSON(data) + assert.NoError(t, err) + assert.Contains(t, string(bytes), "naruto") +} diff --git a/go.mod b/go.mod index f56c02f..f96b1f8 100644 --- a/go.mod +++ b/go.mod @@ -4,11 +4,13 @@ go 1.17 require ( github.com/gin-gonic/gin v1.7.2 + github.com/stretchr/testify v1.4.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 @@ -20,6 +22,7 @@ require ( 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