Code Monkey home page Code Monkey logo

xorcare / golden Goto Github PK

View Code? Open in Web Editor NEW
29.0 29.0 4.0 268 KB

Package golden testing with golden files in Go. A golden file is the expected output of test, stored as a separate file rather than as a string literal inside the test code.

Home Page: https://pkg.go.dev/github.com/xorcare/golden

License: BSD 3-Clause "New" or "Revised" License

Go 94.22% Makefile 5.78%
go go-library go-package golang golden golden-tests mit testdata testing tests

golden's Introduction

golden's People

Contributors

dependabot[bot] avatar xorcare avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

golden's Issues

Add support for updating files via environment variable

When updating via a flag, errors may occur when the flag is not available in the abort of available flags in tests that do not use golden, therefore it is proposed to use an environment variable for these purposes.

func init() {
	update := func() bool {
		const flagname = "GOLDEN_UPDATE"
		flagval := os.Getenv(flagname)
		if flagval == "" {
			flagval = strconv.FormatBool(false)
		}

		b, err := strconv.ParseBool(flagval)
		if err != nil {
			panic(fmt.Sprintf("cannot parse flag %q, err: %v", flagname, err))
		}

		return b
	}

	tool.flag = flag.Bool("update", update(), "update test golden files")
}

Original Russian text:

Добавить поддержку для обновления файлов через переменную среды

При обновлении через флаг могут возникать ошибки отсутствия флага в наборе доступных флагов, в тех тестах в которых не используется golden по этому предлагается использовать для этих целей переменную окружения.

Make a method for reading JSON input files

The method is needed to read JSON data with validation of the data.

var _ bytes.Buffer = golden.JSONRe(t)
// OR
var _ bytes.Buffer = golden.ReadJSON(t)

Original Russian text:

Сделать метод для чтения именно JSON входных файлов
Метод нужен для чтения данных JSON с проверкой валидности данных.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.