entity_test.gno
1.28 Kb · 44 lines
1package entity
2
3import (
4 "testing"
5
6 "gno.land/p/nt/testutils/v0"
7 "gno.land/p/nt/uassert/v0"
8)
9
10// This package is an API sketch recovered from an unmerged upstream proposal:
11// it declares the Entity abstraction and its user/realm refinements, but all
12// three constructors are `panic("not implemented")`. The tests pin that surface
13// so implementing one is a deliberate, visible change.
14
15func TestConstructorsAreNotImplemented(cur realm, t *testing.T) {
16 addr := testutils.TestAddress("alice")
17
18 uassert.PanicsWithMessage(t, cur, "not implemented", func() { NewUserByAddr(addr) })
19 uassert.PanicsWithMessage(t, cur, "not implemented", func() { NewUserByName("alice") })
20}
21
22// TestInterfacesAreDeclared is a compile-time check that the interface
23// hierarchy still exists with its documented shape.
24func TestInterfacesAreDeclared(t *testing.T) {
25 var (
26 _ Entity
27 _ Kind
28 _ UserEntity
29 _ RealmEntity
30 )
31 uassert.True(t, true, "entity interfaces are declared")
32}
33
34// TestRefinementsEmbedEntity pins that UserEntity and RealmEntity are still
35// refinements of Entity — assigning them to an Entity must compile.
36func TestRefinementsEmbedEntity(t *testing.T) {
37 var (
38 u UserEntity
39 r RealmEntity
40 )
41 var _ Entity = u
42 var _ Entity = r
43 uassert.True(t, true, "UserEntity and RealmEntity satisfy Entity")
44}