New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/ipcf/testing

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/ipcf/testing

  • v0.0.0-20191209180336-ecc09d6c0fc2
  • Source
  • Go
  • Socket score

Version published
Created
Source

testing

NOTE: Still in early beta and subject to breaking API changes

A assertion package, for cuelang.

Usage

Given github.com/ipcf/foo/foo.cue:

package foo

Bar: =~ "^([foo]|[bar])+$"

one might define tests as follows github.com/ipcf/foo/test/foo.cue:

package test

import "github.com/ipcf/testing"

import "github.com/ipcf/foo"

testing.T & {
	test: "foo.Bar": {
		[testing.NumDot]: subject: foo.Bar
		"0": assert: ok:     "foo"
		"1": assert: notOk:  "foobar" // will fail
		"2": assert: ok:     "bar"
		"3": assert: ok:     "barfoo"
		"4": assert: ok:     "barfoo"
		"5": assert: ok:     "barfoofoobarfoo"
		"6": assert: notOk:  ""
		"7": assert: notOk:  "bar1"
		"8": assert: notOk:  "1bar"
		"9": assert: notOk:  int
		"10": assert: notOk: null
		"11": assert: notOk: {}
	}
}

and then evaluate package in the test/ directory:

foo/test [master] » cue eval
test: {
    BarBaz: {
        "0": {
            subject: =~"^([foo]|[bar])+$"
            assert: {
                ok:   "foo"
                pass: true
            }
        }
        "1": {
            subject: =~"^([foo]|[bar])+$"
.
.
.

Kind of a lot of output so let's just look at failed tests:

foo/test [master] » cue eval --expression FAIL
BarBaz: {
    "1": {
        subject: =~"^([foo]|[bar])+$"
        assert: {
            pass:  false
            notOk: "foobar"
        }
    }
}

Looks like BarBaz: "1": notOk: "foobar" failed :+1

LICENSE

MIT License, see LICENSE

FAQs

Package last updated on 09 Dec 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc