Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gno testing CI #22

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflow/api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: api
DIGIX666 marked this conversation as resolved.
Show resolved Hide resolved

on:
pull_request:

push:
branches: [ "main" ]
DIGIX666 marked this conversation as resolved.
Show resolved Hide resolved

jobs:

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
- run: go run github.com/gnolang/gno/gnovm/cmd/gno test -v ./...
68 changes: 68 additions & 0 deletions api/r/memeland/memeland_test.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package memeland

import (
"std"
"testing"
"time"
"sort"

"gno.land/p/demo/memeland"
)

// func TestPostMeme(t *testing.T) {
DIGIX666 marked this conversation as resolved.
Show resolved Hide resolved
// m := memeland.NewMemeland()
// data := "Test meme data"
// timestamp := time.Now().Unix()
// id := m.PostMeme(data, timestamp)
// if id == "" {
// t.Errorf("Expected valid ID, got empty string")
// }
// }


// func TestUpvote(t *testing.T) {
// m := memeland.NewMemeland()
// id := m.PostMeme("Another test meme", time.Now().Unix())
// result := m.Upvote(id)
// if result != "upvote successful" {
// t.Errorf("Expected 'upvote successful', got %s", result)
// }
// }


// func TestGetPostsInRange(t *testing.T) {
// m := memeland.NewMemeland()
// startTimestamp := time.Now().Add(-24 * time.Hour).Unix()
// endTimestamp := time.Now().Unix()
// page, pageSize := 1, 10
// sortBy := "DATE_CREATED"
// m.PostMeme("Old Meme", startTimestamp-10)
// m.PostMeme("New Meme", endTimestamp-10)
// result := m.GetPostsInRange(startTimestamp, endTimestamp, page, pageSize, sortBy)
// if result == "" || result == "[]" {
// t.Errorf("Expected non-empty result, got %s", result)
// }
// }


// func TestRemovePost(t *testing.T) {
// m := memeland.NewMemeland()
// id := m.PostMeme("Meme to be deleted", time.Now().Unix())
// removedID := m.RemovePost(id)
// if removedID != id {
// t.Errorf("Expected %s to be removed, got %s", id, removedID)
// }
// }

// NOT PASS FOR THE MOMENT
func TestTransferOwnership(t *testing.T) {
m := memeland.NewMemeland()
newOwner := "g1newowneraddress"
err := m.TransferOwnership(std.Address(newOwner))
if err != nil {
t.Errorf("Expected no error, got %s", err)
}
if m.Owner() != std.Address(newOwner) {
t.Errorf("Expected new owner to be %s, got %s", newOwner, m.Owner())
}
}
45 changes: 45 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module memeland

go 1.22.0

require github.com/gnolang/gno v0.0.0-20240417075834-3297d0c3282b

require (
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect
github.com/gnolang/overflow v0.0.0-20170615021017-4d914c927216 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/jaekwon/testify v1.6.1 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/peterbourgon/ff/v3 v3.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
go.opentelemetry.io/otel v1.25.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.25.0 // indirect
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/sdk v1.25.0 // indirect
go.opentelemetry.io/otel/sdk/metric v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
go.opentelemetry.io/proto/otlp v1.1.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.19.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
google.golang.org/grpc v1.63.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading