Skip to content

Commit

Permalink
Small fix to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shleikes committed Dec 8, 2024
1 parent f6fec7b commit 93dc8f0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
9 changes: 3 additions & 6 deletions protocol/chainlib/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"net/http"
"strconv"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -94,10 +93,9 @@ func TestGRPCGetSupportedApi(t *testing.T) {
}
apiCont, err = apip.getSupportedApi("API2", connectionType_test)
if err == nil {
require.True(t, apiCont.api.Name == "Default-API2")
require.Equal(t, "Default-API2", apiCont.api.Name)
} else {
found := strings.Contains(err.Error(), "api not supported")
require.True(t, found)
require.Contains(t, err.Error(), "api not supported")
}

// Test case 3: Returns error if the API is disabled
Expand All @@ -108,8 +106,7 @@ func TestGRPCGetSupportedApi(t *testing.T) {
}
_, err = apip.getSupportedApi("API1", connectionType_test)
assert.Error(t, err)
found := strings.Contains(err.Error(), "api is disabled")
require.True(t, found)
require.Contains(t, err.Error(), "api is disabled")
}

func TestGRPCParseMessage(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions protocol/chainlib/jsonRPC_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestJSONGetSupportedApi(t *testing.T) {
}
apiCont, err := apip.getSupportedApi("API2", connectionType_test, "")
if err == nil {
require.True(t, apiCont.api.Name == "Default-API2")
assert.Equal(t, "Default-API2", apiCont.api.Name)
} else {
assert.ErrorIs(t, err, common.APINotSupportedError)
}
Expand Down Expand Up @@ -504,7 +504,7 @@ func TestJsonRpcInternalPathsMultipleVersionsAvalanche(t *testing.T) {
require.Equal(t, correctPath, collection.CollectionData.InternalPath)
} else {
if err == nil {
require.True(t, strings.Contains(chainMessage.GetApi().Name, "Default-"))
require.Contains(t, chainMessage.GetApi().Name, "Default-")
} else {
require.ErrorIs(t, err, common.APINotSupportedError)
require.Nil(t, chainMessage)
Expand Down
4 changes: 2 additions & 2 deletions protocol/chainlib/rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestRestGetSupportedApi(t *testing.T) {
}
apiCont, err := apip.getSupportedApi("API2", connectionType_test)
if err == nil {
require.True(t, apiCont.api.Name == "Default-API2")
assert.Equal(t, "Default-API2", apiCont.api.Name)
} else {
assert.ErrorIs(t, err, common.APINotSupportedError)
}
Expand Down Expand Up @@ -318,7 +318,7 @@ func TestRegexParsing(t *testing.T) {
} {
chainMessage, err := chainParser.ParseMsg(api, nil, http.MethodGet, nil, extensionslib.ExtensionInfo{LatestBlock: 0})
if err == nil {
require.True(t, chainMessage.GetApi().GetName() == "Default-"+api)
require.Equal(t, "Default-"+api, chainMessage.GetApi().GetName())
} else {
assert.ErrorIs(t, err, common.APINotSupportedError)
}
Expand Down
2 changes: 1 addition & 1 deletion protocol/chainlib/tendermintRPC_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestTendermintGetSupportedApi(t *testing.T) {
}
apiCont, err := apip.getSupportedApi("API2", connectionType_test)
if err == nil {
require.True(t, apiCont.api.Name == "Default-API2")
assert.Equal(t, "Default-API2", apiCont.api.Name)
} else {
assert.ErrorIs(t, err, common.APINotSupportedError)
}
Expand Down

0 comments on commit 93dc8f0

Please sign in to comment.