You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/AndrewHany/assertions

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/AndrewHany/assertions

v1.0.13
Source
Go
Version published
Created
Source

assertions

Assertion style package, supporting custom assertions

GoDoc

This package is build on top of github.com/smarty/assertions package

it allows custom assertions on fields and types

you basically do

	customAssertions := map[string]assertions.AssertionFunc{
		"$.Field1.Field2":   assertions.SkipAssertion,
		assertion.TimeType:  assertions.AssertTimeToDuration(time.Second),
		assertion.FloatType: assertions.AssertFloat64ToDecimalPlaces(2),
		"$.Field1[][]":      customAssertionFunc,
	}

and pass this assertion map to the assert function For example

  • "$.Field1.Field2": assertions.SkipAssertion, references nested fields in root struct, and skips assertion
  • assertion.TimeType: assertions.AssertTimeToDuration(time.Second) asserts till seconds (skip milliesconds)
  • assertion.FloatType: assertions.AssertFloat64ToDecimalPlaces(2) asserts till the first 2 decimal places
  • "$.Field1[][]": customAssertionFunc Or you can build your custom assertion method

FAQs

Package last updated on 25 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts