https://github.com/h1alexbel/fsl
FakeHub State Language. DSL for managing state in fakehub
https://github.com/h1alexbel/fsl
fakehub programming-language testing testing-fixtures transpiler
Last synced: 10 months ago
JSON representation
FakeHub State Language. DSL for managing state in fakehub
- Host: GitHub
- URL: https://github.com/h1alexbel/fsl
- Owner: h1alexbel
- License: mit
- Created: 2024-09-11T15:35:24.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-15T14:47:45.000Z (11 months ago)
- Last Synced: 2025-03-26T00:11:13.355Z (10 months ago)
- Topics: fakehub, programming-language, testing, testing-fixtures, transpiler
- Language: Rust
- Homepage:
- Size: 534 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# fsl. FakeHub State Language
[](https://www.elegantobjects.org)
[](http://www.rultor.com/p/h1alexbel/fsl)
[](https://www.jetbrains.com/idea/)
[](https://github.com/h1alexbel/fsl/actions/workflows/just.yml)
[](https://crates.io/crates/fsl)
[](https://codecov.io/github/h1alexbel/fsl)
[](http://www.0pdd.com/p?name=h1alexbel/fsl)
[](https://hitsofcode.com/view/github/h1alexbel/fsl)
[](https://github.com/h1alexbel/fsl/blob/master/LICENSE.txt)
[](https://snyk.io/test/github/h1alexbel/fsl)
FSL is a specific [DSL] for managing state inside [fakehub].
**Motivation**. When working with [fakehub], automated testing tool that mocks
GitHub REST API, we often require to setup initial state of the system with
testing data. Instead of repeating testing preparations, we developed
FSL, a language that takes file as an input, processes it, and creates FakeHub
instance with desired data.
## Quick Start
First, install `fsl` from [crates][fsl-crates]:
```bash
cargo add fsl
```
Then, create `init.fsl`:
```fsl
me: @jeff
+repo me/foo > foo
+repo me/bar
+issue "this is testing" +label "bug" -> foo
```
Here, we logged in as `@jeff` fake GitHub user, created two repositories:
`jeff/foo`, `jeff/bar`, submitted new issue with title `"this is testing"` and
`"bug"` label to `jeff/foo`.
And then transpile it:
```rust
use fsl::transpiler::fsl_transpiler::Fslt;
use std::path::Path;
let output = Fslt::file(Path::new("init.fsl")).out();
// output...
```
This should transpile `init.fsl` to [fakehub-compatible][fakehub] output in
[JSON] format.
### Apply to fakehub
To apply it on fakehub, run (make sure you have [fakehub] installed):
```bash
fakehub start --include init.fsl -d
```
Then, pull newly created data:
```bash
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer @jeff" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http://localhost:3000/repos/jeff/foo/issues/1
```
Response should be:
```json
{
"url": "http://localhost:3000/repos/jeff/foo/issues/1",
"repository_url": "http://localhost:3000/repos/jeff/foo",
"labels_url": "http://localhost:3000/repos/jeff/foo/issues/1/labels{/name}",
...
}
```
## How to contribute?
Make sure that you have [Rust] and [just] installed on your system, then fork
this repository, make changes, send us a [pull request][guidelines]. We will
review your changes and apply them to the `master` branch shortly, provided
they don't violate our quality standards. To avoid frustration, before sending
us your pull request please run full build:
```bash
just full
```
[fakehub]: https://github.com/h1alexbel/fakehub
[DSL]: https://en.wikipedia.org/wiki/Domain-specific_language
[guidelines]: https://www.yegor256.com/2014/04/15/github-guidelines.html
[Rust]: https://www.rust-lang.org/tools/install
[just]: https://just.systems/man/en/chapter_4.html
[fsl-crates]: https://crates.io/crates/fsl
[JSON]: https://en.wikipedia.org/wiki/JSON