6 releases

0.0.6 Oct 16, 2024
0.0.5 Oct 16, 2024
0.0.1 Sep 24, 2024

#220 in Testing

43 downloads per month

MIT license

47KB
618 lines

fsl. FakeHub State Language

EO principles respected here DevOps By Rultor.com We recommend IntelliJ IDEA

just Crates.io Version codecov PDD status Hits-of-Code License Known Vulnerabilities

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:

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.

Apply to fakehub

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}",
  ...
}

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. 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

Dependencies

~8MB
~164K SLoC