Skip to content

Commit

Permalink
CI script: Test /chain/XXX/mint/params (#327)
Browse files Browse the repository at this point in the history
* ci script for mint params

* update mint params script
  • Loading branch information
PrathyushaLakkireddy authored Dec 13, 2021
1 parent f0c3de3 commit 3639e32
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/chains/mint_params_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
})
}
}

0 comments on commit 3639e32

Please sign in to comment.