Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

render_test.gno

5.35 Kb · 136 lines
  1package forge
  2
  3// Every route is pinned by an example: a realm's Render is its whole public
  4// surface, and output that varies between identical calls is a consensus bug.
  5// Examples run after every Test, so each one re-seeds the state it renders.
  6
  7// ExampleRender pins the forge home page.
  8func ExampleRender() {
  9	seedFixture()
 10	print(Render(""))
 11	// Output:
 12	// # Forge
 13	//
 14	// An on-chain software forge. The objects stay in git; the chain keeps the part a forge is trusted for: which object a ref points at, in what order, on whose authority, and what was reviewed before it moved.
 15	//
 16	// **Repos:** 1
 17	//
 18	// | repo | refs | issues | changes | log |
 19	// | --- | ---: | ---: | ---: | ---: |
 20	// | [moul/forge](/r/moul/forge/v0:moul/forge) | 1 | 1/1 | 1/1 | 2 |
 21	//
 22	// [Create a repo](/r/moul/forge/v0$help&func=CreateRepo) · [How it works](/r/moul/forge/v0:help)
 23}
 24
 25// ExampleRenderRepo pins a repo overview.
 26func ExampleRenderRepo() {
 27	seedFixture()
 28	print(Render("moul/forge"))
 29	// Output:
 30	// # moul/forge
 31	//
 32	// an on chain software forge
 33	//
 34	// - **Default ref:** `refs/heads/main` → `bbbbbbbbbbbb`
 35	// - **Merge policy:** 1 writer approval(s), self-approval off
 36	// - **Members:** 3
 37	// - **Log head:** `07ca3613cc68e1dc`
 38	// - **Fetch from:** `https://github.com/moul/gno-contracts.git`
 39	//
 40	// ## Refs
 41	//
 42	// - `refs/heads/main` → `bbbbbbbbbbbb` · block 102 · [g1vdshymmvta047h6lta047h6lta047h6l2asz94](/u/g1vdshymmvta047h6lta047h6lta047h6l2asz94)
 43	//
 44	// ## Recent log
 45	//
 46	// - `#1` **update** `refs/heads/main` `aaaaaaaaaaaa` → `bbbbbbbbbbbb` · block 102 · [g1vdshymmvta047h6lta047h6lta047h6l2asz94](/u/g1vdshymmvta047h6lta047h6lta047h6l2asz94) · add the log
 47	// - `#0` **create** `refs/heads/main` (none) → `aaaaaaaaaaaa` · block 101 · [g1vdshymmvta047h6lta047h6lta047h6l2asz94](/u/g1vdshymmvta047h6lta047h6lta047h6l2asz94) · initial import
 48	//
 49	// [Full log, 2 entries](/r/moul/forge/v0:moul/forge/log)
 50	//
 51	// ## Open change requests
 52	//
 53	// - [\!0 record every ref move](/r/moul/forge/v0:moul/forge/changes/0) · **open** · `refs/heads/main` · 1/1 approvals
 54	//
 55	// [All changes, 1 total](/r/moul/forge/v0:moul/forge/changes) · [Propose a change](/r/moul/forge/v0$help&func=OpenChange&repoID=moul%2Fforge)
 56	//
 57	// ## Open issues
 58	//
 59	// - [\#0 force pushes are invisible](/r/moul/forge/v0:moul/forge/issues/0) · **open** · [g1v4mx2h6lta047h6lta047h6lta047h6lslgc76](/u/g1v4mx2h6lta047h6lta047h6lta047h6lslgc76) · 1 replies
 60	//
 61	// [All issues, 1 total](/r/moul/forge/v0:moul/forge/issues) · [Open an issue](/r/moul/forge/v0$help&func=OpenIssue&repoID=moul%2Fforge)
 62}
 63
 64// ExampleRenderLog pins the reference log.
 65func ExampleRenderLog() {
 66	seedFixture()
 67	print(Render("moul/forge/log"))
 68	// Output:
 69	// # moul/forge: reference log
 70	//
 71	// Append-only and hash-chained: every entry commits to the one before it, so pinning the head digest anywhere off chain pins this whole history.
 72	//
 73	// **Head:** `07ca3613cc68e1dc` · **Entries:** 2
 74	//
 75	// - `#1` **update** `refs/heads/main` `aaaaaaaaaaaa` → `bbbbbbbbbbbb` · block 102 · [g1vdshymmvta047h6lta047h6lta047h6l2asz94](/u/g1vdshymmvta047h6lta047h6lta047h6l2asz94) · add the log
 76	// - `#0` **create** `refs/heads/main` (none) → `aaaaaaaaaaaa` · block 101 · [g1vdshymmvta047h6lta047h6lta047h6l2asz94](/u/g1vdshymmvta047h6lta047h6lta047h6l2asz94) · initial import
 77}
 78
 79// ExampleRenderIssue pins one issue.
 80func ExampleRenderIssue() {
 81	seedFixture()
 82	print(Render("moul/forge/issues/0"))
 83	// Output:
 84	// # #0 force pushes are invisible
 85	//
 86	// **open** · opened at block 103 by [g1v4mx2h6lta047h6lta047h6lta047h6lslgc76](/u/g1v4mx2h6lta047h6lta047h6lta047h6lslgc76)
 87	//
 88	// **Labels:** `bug`
 89	//
 90	// A maintainer can rewrite a branch and nothing records it\.
 91	//
 92	// ## Replies (1)
 93	//
 94	// - [g1vfhkyh6lta047h6lta047h6lta047h6l03vdhu](/u/g1vfhkyh6lta047h6lta047h6lta047h6l03vdhu) at block 104: that is what the log is for
 95	//
 96	// [Reply](/r/moul/forge/v0$help&func=CommentIssue&issueID=0&repoID=moul%2Fforge) · [Close](/r/moul/forge/v0$help&func=CloseIssue&issueID=0&repoID=moul%2Fforge) · [Back to issues](/r/moul/forge/v0:moul/forge/issues)
 97}
 98
 99// ExampleRenderChange pins one change request.
100func ExampleRenderChange() {
101	seedFixture()
102	print(Render("moul/forge/changes/0"))
103	// Output:
104	// # !0 record every ref move
105	//
106	// **open** · opened at block 105 by [g1vdshymmvta047h6lta047h6lta047h6l2asz94](/u/g1vdshymmvta047h6lta047h6lta047h6l2asz94)
107	//
108	// - **Head:** `cccccccccccc` (from this repo `refs/heads/feat`)
109	// - **Target:** `refs/heads/main` → `bbbbbbbbbbbb`
110	// - **Approvals:** 1 of 1 required
111	// - **Blocking:** 0
112	//
113	// closes 0
114	//
115	// ## Reviews (1)
116	//
117	// - [g1vfhkyh6lta047h6lta047h6lta047h6l03vdhu](/u/g1vfhkyh6lta047h6lta047h6lta047h6l03vdhu): **approve** on `cccccccccccc`: lgtm
118	//
119	// ## Replies (0)
120	//
121	// None yet.
122	//
123	// [Review](/r/moul/forge/v0$help&func=ReviewChange&changeID=0&repoID=moul%2Fforge&verdict=approve) · [Reply](/r/moul/forge/v0$help&func=CommentChange&changeID=0&repoID=moul%2Fforge) · [Merge](/r/moul/forge/v0$help&func=MergeChange&changeID=0&expectedTargetOID=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb&repoID=moul%2Fforge) · [Back to changes](/r/moul/forge/v0:moul/forge/changes)
124}
125
126// ExampleRenderNotFound pins an unknown repo.
127func ExampleRenderNotFound() {
128	seedFixture()
129	print(Render("moul/nope"))
130	// Output:
131	// # Not found
132	//
133	// no repo `moul/nope`.
134	//
135	// [Back to the forge](/r/moul/forge/v0)
136}