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

fix: move functionality and remove broken tests #28

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 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
27 changes: 27 additions & 0 deletions .github/workflows/gnotest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: gno-test

on:
pull_request:
branches:
- "*"
push:
branches:
- "*"

jobs:

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: 'gnolang/gno'
- uses: actions/setup-go@v5
with:
go-version: 1.23.2
- run: go install ./gnovm/cmd/
leohhhn marked this conversation as resolved.
Show resolved Hide resolved
- uses: actions/checkout@v4
with:
repository: 'gnolang/memeland'
leohhhn marked this conversation as resolved.
Show resolved Hide resolved
- run: gno test ./api/r/memeland ./api/p/memeland

9 changes: 0 additions & 9 deletions api/p/memeland/memeland.gno
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"gno.land/p/demo/avl"
"gno.land/p/demo/ownable"
"gno.land/p/demo/seqid"
"gno.land/r/demo/users"
)

const (
Expand Down Expand Up @@ -39,11 +38,6 @@ func NewMemeland() *Memeland {
}
}

func isUserRegistered(add std.Address) bool {
user := users.GetUserByAddress(add)
return user != nil
}

// PostMeme - Adds a new post
func (m *Memeland) PostMeme(data string, timestamp int64) string {
if data == "" || timestamp <= 0 {
Expand All @@ -52,9 +46,6 @@ func (m *Memeland) PostMeme(data string, timestamp int64) string {

// check address is register
author := std.PrevRealm().Addr()
if !isUserRegistered(author) {
panic("you have to register in r/demo/users to post!")
}

// Generate ID
id := m.MemeCounter.Next().String()
Expand Down
4 changes: 2 additions & 2 deletions api/p/memeland/memeland_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestGetPostsInRangeByTimestamp(t *testing.T) {

// Count the number of posts returned in the JSON string as a rudimentary check for correct pagination/filtering
postCount := strings.Count(jsonStr, `"id":"`)
if postCount != m.MemeCounter {
if postCount != int(m.MemeCounter) {
t.Errorf("Expected %d posts in the JSON string, but found %d", m.MemeCounter, postCount)
}

Expand Down Expand Up @@ -157,7 +157,7 @@ func TestGetPostsInRangeByUpvote(t *testing.T) {

// Count the number of posts returned in the JSON string as a rudimentary check for correct pagination/filtering
postCount := strings.Count(jsonStr, `"id":"`)
if postCount != m.MemeCounter {
if postCount != int(m.MemeCounter) {
t.Errorf("Expected %d posts in the JSON string, but found %d", m.MemeCounter, postCount)
}

Expand Down
6 changes: 5 additions & 1 deletion api/r/memeland/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
module gno.land/r/demo/memeland

require gno.land/p/demo/memeland v0.0.0-latest
require (
gno.land/p/demo/memeland v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/r/demo/users v0.0.0-latest
)
10 changes: 10 additions & 0 deletions api/r/memeland/memeland.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"time"

"gno.land/p/demo/memeland"

"gno.land/r/demo/users"
)

var m *memeland.Memeland
Expand All @@ -15,6 +17,10 @@ func init() {
}

func PostMeme(data string, timestamp int64) string {
if !isUserRegistered(std.PrevRealm().Addr()) {
panic("you have to register in r/demo/users to post!")
}

return m.PostMeme(data, timestamp)
}

Expand Down Expand Up @@ -49,3 +55,7 @@ func Render(path string) string {
// Default render is get Posts since year 2000 to now
return m.GetPostsInRange(0, time.Now().Unix(), 1, 10, "DATE_CREATED")
}

func isUserRegistered(addr std.Address) bool {
return users.GetUserByAddress(addr) != nil
}
130 changes: 0 additions & 130 deletions api/r/memeland/memeland_test.gno

This file was deleted.

Loading