github.com/15mga/kiwi@v0.0.2-0.20240324021231-b95d5c3ac751/graph/marshall/graph_test.go (about) 1 package marshall 2 3 import ( 4 "github.com/15mga/kiwi/graph" 5 "github.com/15mga/kiwi/util" 6 "github.com/stretchr/testify/assert" 7 "testing" 8 ) 9 10 var str = ` 11 graph TD 12 signIn[登录] 13 signUp[注册] 14 characterCreate[创建角色] 15 characterGet[获取角色] 16 characterEquipChange[更换装备] 17 roomList[获取房间列表] 18 roomEnter[进入房间] 19 sceneCharacterUpdate[角色位置更新] 20 roomExit[退出房间] 21 over[结束] 22 signUp --> |fail->error->fail| over 23 signUp --> |success->empty->create| characterCreate 24 signIn --> |success->empty->get| characterGet 25 signIn --> |fail->account->signUp| signUp 26 characterCreate --> |success->empty->get| characterGet 27 characterCreate --> |fail->error->fail| over 28 characterGet --> |success->empty->change| characterEquipChange 29 characterGet --> |success->empty->end| over 30 characterEquipChange --> |success->empty->get| roomList 31 characterEquipChange --> |fail->empty->get| roomList 32 roomList --> |success->int64->enter| roomEnter 33 roomList --> |fail->error->fail| over 34 roomEnter --> |success->empty->update| sceneCharacterUpdate 35 sceneCharacterUpdate --> |success->empty->update| roomExit 36 roomExit --> |success->empty->get| roomList 37 roomExit --> |over->empty->end| over` 38 39 func TestGraph_Unmarshall(t *testing.T) { 40 g := graph.NewGraph("test") 41 ug := &Graph{} 42 err := ug.Unmarshall(util.StrToBytes(str), g) 43 assert.Nil(t, err) 44 }