Some checks failed
Docs Deploy / build_and_deploy (push) Has been cancelled
Generate Docs / cli (push) Has been cancelled
Generate Config Doc / cli (push) Has been cancelled
Go formatting / go-formatting (push) Has been cancelled
Check links / markdown-link-check (push) Has been cancelled
Integration / pre-test (push) Has been cancelled
Integration / test on (push) Has been cancelled
Integration / status (push) Has been cancelled
Lint / Lint Go code (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
184 lines
3.3 KiB
Go
184 lines
3.3 KiB
Go
//go:build !relayer
|
|
|
|
package map_test
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
envtest "git.cw.tr/mukan-network/mukan-ignite/integration"
|
|
)
|
|
|
|
func TestCreateMap(t *testing.T) {
|
|
var (
|
|
env = envtest.New(t)
|
|
app = env.ScaffoldApp("github.com/test/blog")
|
|
servers = app.RandomizeServerPorts()
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map",
|
|
false,
|
|
"map", "user", "user-id", "email",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map with custom path",
|
|
false,
|
|
"map", "appPath", "email", "--path", filepath.Join(app.SourcePath(), "app"),
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map with no message",
|
|
false,
|
|
"map", "nomessage", "email", "--no-message",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a module",
|
|
false,
|
|
"module", "example", "--require-registration",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a list",
|
|
false,
|
|
"list",
|
|
"user",
|
|
"email",
|
|
"--module",
|
|
"example",
|
|
"--no-simulation",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map with decimal coin",
|
|
false,
|
|
"map",
|
|
"decimal",
|
|
"deccointype:dec.coin",
|
|
"deccoins:dec.coins",
|
|
"--module",
|
|
"example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"should prevent creating a map with a typename that already exist",
|
|
true,
|
|
"map", "user", "email", "--module", "example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map in a custom module",
|
|
false,
|
|
"map", "mapUser", "email", "--module", "example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map with a custom field type",
|
|
false,
|
|
"map", "mapDetail", "user:MapUser", "--module", "example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map with a custom array field type",
|
|
false,
|
|
"map", "mapDetailArray", "users:array.MapUser", "--module", "example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"should prevent creating a map with invalid custom array field type",
|
|
true,
|
|
"map", "mapInvalidDetailArray", "users:array.UnknownType", "--module", "example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map with Coin and []Coin",
|
|
false,
|
|
"map",
|
|
"salary",
|
|
"numInt:int",
|
|
"numsInt:array.int",
|
|
"numsIntAlias:ints",
|
|
"numUint:uint",
|
|
"numsUint:array.uint",
|
|
"numsUintAlias:uints",
|
|
"textString:string",
|
|
"textStrings:array.string",
|
|
"textStringsAlias:strings",
|
|
"textCoin:coin",
|
|
"textCoinsAlias:coins",
|
|
"--module",
|
|
"example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map with Coin and Coins",
|
|
false,
|
|
"map",
|
|
"budget",
|
|
"textCoin:coin",
|
|
"textCoins:array.coin",
|
|
"--module",
|
|
"example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map with index",
|
|
false,
|
|
"map",
|
|
"map_with_index",
|
|
"email",
|
|
"emailIds:ints",
|
|
"--index",
|
|
"bar:int",
|
|
"--module",
|
|
"example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map with invalid index (multi-index)",
|
|
true,
|
|
"map",
|
|
"map_with_invalid_index",
|
|
"email",
|
|
"--index",
|
|
"foo:strings,bar:int",
|
|
"--module",
|
|
"example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a map with invalid index (invalid type)",
|
|
true,
|
|
"map",
|
|
"map_with_invalid_index",
|
|
"email",
|
|
"--index",
|
|
"foo:unknown",
|
|
"--module",
|
|
"example",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a message and a map with no-message flag to check conflicts",
|
|
false,
|
|
"message", "create-scavenge", "description",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"create a message and a map with no-message flag to check conflicts",
|
|
false,
|
|
"map", "scavenge", "description", "--no-message",
|
|
)
|
|
|
|
app.Scaffold(
|
|
"should prevent creating a map with an index present in fields",
|
|
true,
|
|
"map", "map_with_invalid_index", "email", "--index", "email",
|
|
)
|
|
|
|
app.EnsureSteady()
|
|
|
|
app.RunChainAndSimulateTxs(servers)
|
|
}
|