Skip to content

Commit

Permalink
chore: add fetchers tests (#72)
Browse files Browse the repository at this point in the history
* chore: add cosmos LCD fetcher tests

* chore: add assets

* chore: add cosmos RPC fetcher tests
  • Loading branch information
freak12techno authored Aug 29, 2024
1 parent 274e704 commit 071582e
Show file tree
Hide file tree
Showing 25 changed files with 6,106 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cover.out
missed-blocks-checker
dist
*.sqlite
**/.DS_Store
**/.DS_Store
9 changes: 9 additions & 0 deletions assets/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ import (

//go:embed *
var EmbedFS embed.FS

func GetBytesOrPanic(path string) []byte {
bytes, err := EmbedFS.ReadFile(path)
if err != nil {
panic(err)
}

return bytes
}
28 changes: 28 additions & 0 deletions assets/fs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package assets

import (
"testing"

"github.com/stretchr/testify/assert"

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

func TestGetPanicOrFailPanic(t *testing.T) {
t.Parallel()

defer func() {
if r := recover(); r == nil {
require.Fail(t, "Expected to have a panic here!")
}
}()

GetBytesOrPanic("not-existing")
}

func TestGetPanicOrFailOk(t *testing.T) {
t.Parallel()

bytes := GetBytesOrPanic("valid.toml")
assert.NotNil(t, bytes)
}
1 change: 1 addition & 0 deletions assets/invalid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalid
Loading

0 comments on commit 071582e

Please sign in to comment.