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.
First, install fsl
from crates:
cargo add fsl
Then, create init.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:
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 output in
JSON format.
To apply it on fakehub, run (make sure you have fakehub installed):
fakehub start --include init.fsl -d
Then, pull newly created data:
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:
{
"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}",
...
}
Make sure that you have Rust and just installed on your system, then fork
this repository, make changes, send us a pull request. 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:
just full