Skip to content

Commit

Permalink
fix: push fail
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz committed Nov 29, 2024
1 parent ad4bc60 commit 5ff7644
Showing 1 changed file with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package gnopkgfetcher

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
)

func TestRpcURLFromPkgPath(t *testing.T) {
cases := []struct {
name string
pkgPath string
overrides map[string]string
result string
errorContains string
}{
{
name: "happy path simple",
pkgPath: "gno.land/p/demo/avl",
result: "https://rpc.gno.land:443",
},
{
name: "happy path override",
pkgPath: "gno.land/p/demo/avl",
overrides: map[string]string{"gno.land": "https://example.com/rpc:42"},
result: "https://example.com/rpc:42",
},
{
name: "happy path override no effect",
pkgPath: "gno.land/p/demo/avl",
overrides: map[string]string{"some.chain": "https://example.com/rpc:42"},
result: "https://rpc.gno.land:443",
},
{
name: "error bad pkg path",
pkgPath: "std",
result: "",
errorContains: fmt.Sprintf("bad pkg path %q", "std"),
},
}

for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
res, err := rpcURLFromPkgPath(c.pkgPath, c.overrides)
if len(c.errorContains) == 0 {
require.NoError(t, err)
} else if err != nil {
require.ErrorContains(t, err, c.errorContains)
}
require.Equal(t, c.result, res)
})
}
}

0 comments on commit 5ff7644

Please sign in to comment.