-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI script: Test /chain/XXX/mint/params (#327)
* ci script for mint params * update mint params script
- Loading branch information
1 parent
f0c3de3
commit 3639e32
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
} | ||
} |