Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/krdlab/haskell-webapp-testing-experimentation
https://github.com/krdlab/haskell-webapp-testing-experimentation
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/krdlab/haskell-webapp-testing-experimentation
- Owner: krdlab
- License: mit
- Created: 2015-10-31T11:16:00.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-01T14:40:22.000Z (about 9 years ago)
- Last Synced: 2024-04-11T03:43:24.606Z (7 months ago)
- Language: Haskell
- Homepage: http://krdlab.hatenablog.com/entry/2015/11/03/122732
- Size: 141 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Web App. Testing experimentation
## Prepare
* Redis
* MySQL
* MailCatcher
* SQLite```sql
-- $ mysql -u root -pCREATE DATABASE main DEFAULT CHARACTER SET utf8mb4;
CREATE TABLE main.user (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(64) NOT NULL,
email_address VARCHAR(128) NOT NULL,
created_at DATETIME NOT NULL,
last_loggedin_at DATETIME NOT NULL,
UNIQUE KEY unique_user_name (name),
UNIQUE KEY unique_user_email_address (email_address)
);
CREATE USER 'tester'@"%" IDENTIFIED BY 'tester';
GRANT ALL PRIVILEGES ON main.* TO 'tester'@"%";
``````sql
-- $ sqlite3 test.dbCREATE TABLE user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR(64) NOT NULL UNIQUE,
email_address VARCHAR(128) NOT NULL UNIQUE,
created_at DATETIME NOT NULL,
last_loggedin_at DATETIME NOT NULL
);
```SQLite uses "main" as a virtual database name. I don't know how to rename it.
Thus both MySQL and SQLite use "main" as a database name here.## Build & Run
```sh
$ git submodule update
$ cabal sandbox init && cabal sandbox add-source hdbc-mysql/
$ cabal build
$ cabal run server
```## Check
```sh
$ curl -X POST \
-H 'Content-Type: application/json' \
-d '{"reg_name":"tester","reg_email_address":"tester@localhost"}' \
http://localhost:8081/register$ curl -X POST \
-H 'Content-Type: application/json' \
-d '{"login_name":"tester"}' \
http://localhost:8081/login$ curl -X GET \
http://localhost:8081/users/2
```## Test
```sh
$ cabal install --only-dependencies --enable-tests
$ cabal configure --enable-tests
$ cabal build
$ cabal test
````registerSpec` uses `MockApp`. `MockApp` emulates IO actions and doesn't access to an external process.