// test "create_action/1 kind: kick, valid" { // user = insert(:user) // user_1 = insert(:user) // user_3 = insert(:user) // user_4 = insert(:user) // commander = insert(:commander) // user_data_one = build(:user_data, %{ // turn: false, position: 0, commander_id: commander.id, user_id: user_1.id // }) // user_data_two = build(:user_data, %{ // turn: true, // user_id: user.id, // commander_id: commander.id, // position: 1 // }) // user_data_three = build(:user_data, %{ // turn: false, // position: 2, // commander_id: commander.id, // user_id: user_3.id, // active: false // }) // user_data_four = build(:user_data, %{ // turn: false, position: 3, commander_id: commander.id, user_id: user_4.id // }) // game = insert(:game, %{ // user_data: [ // user_data_one, // user_data_two, // user_data_three, // user_data_four // ] // }) // insert(:game_user, %{game: game, faction: 1}) // insert(:game_user, %{game: game, faction: 2}) // action = build(:action, %{ // kind: "kick", // game_id: game.id, // user_id: user.id, // system: true // }) // |> Map.from_struct() // assert {:ok, Action { // game: Game { // user_data: [ // UserData {turn: false, position: 1, active: false, state: "kick"}, // UserData {turn: false, position: 2, active: false}, // UserData {turn: true, position: 3, active: true}, // UserData {turn: false, position: 0, active: true} // ] // } // }} = Engine.create_action(action) // } // test "create_action/1 kind: kick, invalid" { // user = insert(:user) // game = insert(:game) // action = build(:action, %{ // kind: "kick", // game_id: game.id, // user_id: user.id // }) // |> Map.from_struct() // assert {:error, Changeset { // errors: [ // kind: {"must be system action", []} // ] // }} = Engine.create_action(action) // }