Skip to content

Commit

Permalink
chore: fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed Jan 14, 2024
1 parent eca0147 commit 793aa89
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 35 deletions.
1 change: 0 additions & 1 deletion examples/gno.land/p/demo/grc/grc721/gno.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ module gno.land/p/demo/grc/grc721

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
)
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/microblog/gno.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ module gno.land/p/demo/microblog

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/users v0.0.0-latest
)
1 change: 0 additions & 1 deletion examples/gno.land/p/demo/microblog/microblog.gno
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"gno.land/p/demo/avl"
"gno.land/p/demo/ufmt"
"gno.land/p/demo/users"
)

var (
Expand Down
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/users/types.gno
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package users

import "std"

type AddressOrName string

func (aon AddressOrName) IsName() bool {
Expand Down
3 changes: 1 addition & 2 deletions examples/gno.land/r/demo/boards/misc.gno
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ func displayAddressMD(addr std.Address) string {
if user == nil {
return "[" + addr.String() + "](/r/demo/users:" + addr.String() + ")"
} else {
return "[@" + user.Name() + "](/r/demo/users:" + user.Name() + ")"
return "[@" + user.Name + "](/r/demo/users:" + user.Name + ")"
}
return "[@" + user.Name + "](/r/users:" + user.Name + ")"
}

func usernameOf(addr std.Address) string {
Expand Down
7 changes: 0 additions & 7 deletions examples/gno.land/r/demo/boards/z_4_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func main() {

// Realm:
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/boards"]
// u[f6dbf411da22e67d74cd7ddba6a76cd7e14a4822:101]={
// "Fields": [
Expand Down Expand Up @@ -962,11 +961,5 @@ func main() {
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/users"]
// switchrealm["gno.land/r/demo/boards"]
// switchrealm["gno.land/r/boards_test"]
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/foo1155/foo1155_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

"gno.land/p/demo/grc/grc1155"
"gno.land/r/demo/users"
"gno.land/p/demo/users"
)

func TestFoo721(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion examples/gno.land/r/demo/foo20/foo20_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"std"
"testing"

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

func TestReadOnlyPublicMethods(t *testing.T) {
Expand Down
6 changes: 4 additions & 2 deletions examples/gno.land/r/demo/foo721/foo721_test.gno
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import (

"gno.land/p/demo/grc/grc721"
"gno.land/r/demo/users"

pusers "gno.land/p/demo/users"
)

func TestFoo721(t *testing.T) {
admin := users.AddressOrName("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj")
hariom := users.AddressOrName("g1var589z07ppjsjd24ukm4uguzwdt0tw7g47cgm")
admin := pusers.AddressOrName("g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj")
hariom := pusers.AddressOrName("g1var589z07ppjsjd24ukm4uguzwdt0tw7g47cgm")

for i, tc := range []struct {
name string
Expand Down
2 changes: 2 additions & 0 deletions examples/gno.land/r/demo/microblog/gno.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module gno.land/r/demo/microblog

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/microblog v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/r/demo/users v0.0.0-latest
)
Original file line number Diff line number Diff line change
Expand Up @@ -7,60 +7,58 @@ import (
"testing"

"gno.land/p/demo/avl"
"gno.land/p/demo/microblog"
"gno.land/p/demo/testutils"
)

func TestMicroblog(t *testing.T) {
const (
title string = "test microblog"
prefix string = "/r/test"
author1 std.Address = testutils.TestAddress("author1")
author2 std.Address = testutils.TestAddress("author2")
)

std.TestSetOrigCaller(author1)

d := NewMicroblog(title, prefix)
if d.Render("/wrongpath") != "404" {
if Render("/wrongpath") != "404" {
t.Fatalf("rendering not giving 404")
}
if d.Render("") == "404" {
if Render("") == "404" {
t.Fatalf("rendering / should not give 404")
}
if err := d.NewPost("goodbyte, web2"); err != nil {
if err := m.NewPost("goodbyte, web2"); err != nil {
t.Fatalf("could not create post")
}
if _, err := d.GetPage(author1.String()); err != nil {
if _, err := m.GetPage(author1.String()); err != nil {
t.Fatalf("silo should exist")
}
if _, err := d.GetPage("no such author"); err == nil {
if _, err := m.GetPage("no such author"); err == nil {
t.Fatalf("silo should not exist")
}

std.TestSetOrigCaller(author2)

if err := d.NewPost("hello, web3"); err != nil {
if err := m.NewPost("hello, web3"); err != nil {
t.Fatalf("could not create post")
}
if err := d.NewPost("hello again, web3"); err != nil {
if err := m.NewPost("hello again, web3"); err != nil {
t.Fatalf("could not create post")
}
if err := d.NewPost("hi again,\n web4?"); err != nil {
if err := m.NewPost("hi again,\n web4?"); err != nil {
t.Fatalf("could not create post")
}

println("--- MICROBLOG ---\n\n")
if rendering := d.Render(""); rendering != `# test microblog
if rendering := Render(""); rendering != `# gno-based microblog
# pages
- [g1v96hg6r0wgc47h6lta047h6lta047h6lm33tq6](/r/testg1v96hg6r0wgc47h6lta047h6lta047h6lm33tq6)
- [g1v96hg6r0wge97h6lta047h6lta047h6lyz7c00](/r/testg1v96hg6r0wge97h6lta047h6lta047h6lyz7c00)
- [g1v96hg6r0wgc47h6lta047h6lta047h6lm33tq6](/r/demo/microblog:g1v96hg6r0wgc47h6lta047h6lta047h6lm33tq6)
- [g1v96hg6r0wge97h6lta047h6lta047h6lyz7c00](/r/demo/microblog:g1v96hg6r0wge97h6lta047h6lta047h6lyz7c00)
` {
t.Fatalf("incorrect rendering /: '%s'", rendering)
}

if rendering := strings.TrimSpace(d.Render(author1.String())); rendering != `## [g1v96hg6r0wgc47h6lta047h6lta047h6lm33tq6](/r/demo/microblog:g1v96hg6r0wgc47h6lta047h6lta047h6lm33tq6)
if rendering := strings.TrimSpace(Render(author1.String())); rendering != `## [g1v96hg6r0wgc47h6lta047h6lta047h6lm33tq6](/r/demo/microblog:g1v96hg6r0wgc47h6lta047h6lta047h6lm33tq6)
joined 2009-13-02, last updated 2009-13-02
Expand All @@ -72,7 +70,7 @@ joined 2009-13-02, last updated 2009-13-02
t.Fatalf("incorrect rendering /: '%s'", rendering)
}

if rendering := strings.TrimSpace(d.Render(author2.String())); rendering != `## [g1v96hg6r0wge97h6lta047h6lta047h6lyz7c00](/r/demo/microblog:g1v96hg6r0wge97h6lta047h6lta047h6lyz7c00)
if rendering := strings.TrimSpace(Render(author2.String())); rendering != `## [g1v96hg6r0wge97h6lta047h6lta047h6lyz7c00](/r/demo/microblog:g1v96hg6r0wge97h6lta047h6lta047h6lyz7c00)
joined 2009-13-02, last updated 2009-13-02
Expand Down

0 comments on commit 793aa89

Please sign in to comment.