rossmacarthur/goldie

Simple golden file testing for Rust

Add the following to your Cargo manifest

goldie

.

goldie::assert!(text);

🚀 Getting started

.

[dev-dependencies]
goldie = "0.1"

In your test function assert the contents using goldie::assert!. The golden filename will be automatically determined based on the test file and test function name. Run tests with GOLDIE_UPDATE=true to automatically update golden files.

// file: module.rs

#[test]
fn example() {
    let text = { /* ... run the test ... */ }

    // assert that the contents of ./testdata/module/example.golden
    // are equal to `text`
    goldie::assert!(text)
}

Templated golden files are also supported using goldie::assert_template!. Something implementing serde::Serialize needs to be provided as context in order to render the template. Values are rendered using TinyTemplate e.g. {value.field}. You cannot use GOLDIE_UPDATE=true to automatically update templated golden files.

// file: module.rs

use serde_json::json;

#[test]
fn example() {
    let text = { /* ... run the test ... */ }

    // first render the golden file ./testdata/module/example.golden
    // with the provided `ctx` then assert that the contents are
    // equal to the result.
    let ctx = json!({"value": "Hello World!"});
    goldie::assert_template!(&ctx, text)
}

License

Licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Information - Updated Nov 29, 2021

Stars: 0
Forks: 0
Issues: 0

CDRS is looking for maintainers

CDRS is Apache Cassandra driver written in pure Rust

CDRS is looking for maintainers

Rust bindings for the C++ api of PyTorch

LIghtweight wrapper for pytorch eg libtorch in rust

Rust bindings for the C++ api of PyTorch

The arkworks ecosystem consist of Rust libraries for designing and working with zero knowledge succinct...

This library is released under the MIT License and the Apache v2 License (see License)

The arkworks ecosystem consist of Rust libraries for designing and working with zero knowledge succinct...

A Rust wrapper library for smealum's ctrulib

A Rust wrapper library for smealum's LICENSE-APACHE, COPYRIGHT for details

A Rust wrapper library for smealum's ctrulib

OpenSearch Rust Client

a community-driven, open source fork of elasticsearch-rs licensed under the Apache v2

OpenSearch Rust Client

A 'Space Invader' clone made with rust and made for the terminal

Inspired by Apache License (Version 2

A 'Space Invader' clone made with rust and made for the terminal

The compact yet complete benchmarking suite for Rust

This project is licensed under the Apache-2

The compact yet complete benchmarking suite for Rust

Rust SDK for Structured Expression Project Toolkit (SEPT)

Copyright 2021 by Victor Dods, licensed under Apache 2

Rust SDK for Structured Expression Project Toolkit (SEPT)

🚶🚶🚶 rust-ingress

This is a POC for ingress solution using Apache Kafka with two services for ingressing and storing messages into Postgres

🚶🚶🚶 rust-ingress

Rust Embedded HAL for Apache NuttX RTOS

This crate provides Rust Embedded HAL interfaces (GPIO, I2C, SPI and Delay) for Apache NuttX RTOS

Rust Embedded HAL for Apache NuttX RTOS
Facebook Instagram Twitter GitHub Dribbble
Privacy