From 3639e326350dd4495cc82c93d699da499e0f2d5b Mon Sep 17 00:00:00 2001 From: Prathyusha Lakkireddy Date: Mon, 13 Dec 2021 19:18:12 +0530 Subject: [PATCH] CI script: Test /chain/XXX/mint/params (#327) * ci script for mint params * update mint params script --- tests/chains/mint_params_test.go | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 tests/chains/mint_params_test.go diff --git a/tests/chains/mint_params_test.go b/tests/chains/mint_params_test.go new file mode 100644 index 00000000..1756a609 --- /dev/null +++ b/tests/chains/mint_params_test.go @@ -0,0 +1,59 @@ +package tests + +import ( + "fmt" + "net/http" + "os" + "testing" + + "github.com/stretchr/testify/require" + + utils "github.com/allinbits/demeris-backend/test_utils" +) + +const ( + mintParamsEndpoint = "chain/%s/mint/params" + paramsKey = "params" +) + +func TestMintParams(t *testing.T) { + t.Parallel() + + // arrange + env := os.Getenv("ENV") + emIngress, _ := utils.LoadIngressInfo(env, t) + require.NotNil(t, emIngress) + + chains := utils.LoadChainsInfo(env, t) + require.NotNil(t, chains) + + client := utils.CreateNetClient(env, t) + require.NotNil(t, client) + + for _, ch := range chains { + t.Run(ch.Name, func(t *testing.T) { + + // arrange + url := fmt.Sprintf(baseUrl+mintParamsEndpoint, emIngress.Protocol, emIngress.Host, emIngress.APIServerPath, ch.Name) + // act + resp, err := client.Get(url) + require.NoError(t, err) + + defer resp.Body.Close() + + // assert + if !ch.Enabled { + require.Equal(t, http.StatusBadRequest, resp.StatusCode, fmt.Sprintf("Chain %s HTTP code %d", ch.Name, resp.StatusCode)) + } else { + require.Equal(t, http.StatusOK, resp.StatusCode, fmt.Sprintf("Chain %s HTTP code %d", ch.Name, resp.StatusCode)) + + var respValues map[string]interface{} + utils.RespBodyToMap(resp.Body, &respValues, t) + + //expect a non empty data + params := respValues[paramsKey] + require.NotEmpty(t, params) + } + }) + } +}