Skip to content
This repository has been archived by the owner on Oct 2, 2018. It is now read-only.

play-card-as-player test #133

Merged
merged 9 commits into from
Sep 6, 2018
Merged

play-card-as-player test #133

merged 9 commits into from
Sep 6, 2018

Conversation

Masclins
Copy link
Collaborator

@Masclins Masclins commented Sep 3, 2018

This should complete the tests of current api/base.clj, solving a point from #55

Resolves #97 (at least the needed messages we came up with)

Copy link
Owner

@kenan-rhoton kenan-rhoton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the missing API error messages should be included here in this commit (at least the API generated ones, Rules generated ones may go separately)

Copy link
Owner

@kenan-rhoton kenan-rhoton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A success test for two cards correctly played by both players is missing, right?

@kenan-rhoton
Copy link
Owner

Also invalid player-id/game-id

@@ -13,12 +13,16 @@
(player-view/get-game-as-player (persistence/fetch-game game-id) player-id))

(defn play-card-as-player
"Plays a card give and returns the game sate as seen by the player"
[game-id player-id card-id row-id & target]
(let [game-state (persistence/fetch-game game-id)]
(if (= (:status (get-game game-id player-id)) messages/play)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if game-state is nil? (Not in the database)

p2 (:player-id (base/add-player game-id))]

(expect {:error messages/invalid-id}
(base/play-card-as-player 9999999999 p1 0 0))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kenan-rhoton apparently "mocking" is making this test not as good as it should be

[game-id player-id card-id row-id & target]
(let [game-state (persistence/fetch-game game-id)]
(if (and (= game-id (:game-id game-state))
(or (= player-id (first (:player-ids game-state)))
(= player-id (second (:player-ids game-state)))))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this can be done prettier... But how?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll open an issue to clean this up cause it would involve changes to mocking, so I dont forget

@kenan-rhoton kenan-rhoton mentioned this pull request Sep 6, 2018
@kenan-rhoton kenan-rhoton merged commit 677c845 into develop Sep 6, 2018
@kenan-rhoton kenan-rhoton deleted the api-test branch September 6, 2018 18:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants