An open API service providing repository metadata for many open source software ecosystems.

Package Usage: go: github.com/frankban/quicktest

Package quicktest provides a collection of Go helpers for writing tests. Quicktest helpers can be easily integrated inside regular Go tests, for instance: An assertion looks like this, where qt.Equals could be replaced by any available checker. If the assertion fails, the underlying Fatal method is called to describe the error and abort the test. If you don’t want to abort on failure, use Check instead, which calls Error instead of Fatal: For really short tests, the extra line for instantiating *qt.C can be avoided: The library provides some base checkers like Equals, DeepEquals, Matches, ErrorMatches, IsNil and others. More can be added by implementing the Checker interface. Below, we list the checkers implemented by the package in alphabetical order. All returns a Checker that uses the given checker to check elements of slice or array or the values of a map. It succeeds if all elements pass the check. On failure it prints the error from the first index that failed. For example: See also Any and Contains. Any returns a Checker that uses the given checker to check elements of a slice or array or the values from a map. It succeeds if any element passes the check. For example: See also All and Contains. CmpEquals checks equality of two arbitrary values according to the provided compare options. DeepEquals is more commonly used when no compare options are required. Example calls: CodecEquals returns a checker that checks for codec value equivalence. It expects two arguments: a byte slice or a string containing some codec-marshaled data, and a Go value. It uses unmarshal to unmarshal the data into an interface{} value. It marshals the Go value using marshal, then unmarshals the result into an interface{} value. It then checks that the two interface{} values are deep-equal to one another, using CmpEquals(opts) to perform the check. See JSONEquals for an example of this in use. Contains checks that a map, slice, array or string contains a value. It's the same as using Any(Equals), except that it has a special case for strings - if the first argument is a string, the second argument must also be a string and strings.Contains will be used. For example: ContentEquals is is like DeepEquals but any slices in the compared values will be sorted before being compared. For example: DeepEquals checks that two arbitrary values are deeply equal. The comparison is done using the github.com/google/go-cmp/cmp package. When comparing structs, by default no exported fields are allowed. If a more sophisticated comparison is required, use CmpEquals (see below). Example call: Equals checks that two values are equal, as compared with Go's == operator. For instance: Note that the following will fail: Use the IsNil checker below for this kind of nil check. ErrorAs checks that the error is or wraps a specific error type. If so, it assigns it to the provided pointer. This is analogous to calling errors.As. For instance: ErrorIs checks that the error is or wraps a specific error value. This is analogous to calling errors.Is. For instance: ErrorMatches checks that the provided value is an error whose message matches the provided regular expression. For instance: HasLen checks that the provided value has the given length. For instance: Implements checks that the provided value implements an interface. The interface is specified with a pointer to an interface variable. For instance: IsFalse checks that the provided value is false. The value must have a boolean underlying type. For instance: IsNil checks that the provided value is nil. For instance: As a special case, if the value is nil but implements the error interface, it is still considered to be non-nil. This means that IsNil will fail on an error value that happens to have an underlying nil value, because that's invariably a mistake. See https://golang.org/doc/faq#nil_error. So it's just fine to check an error like this: IsNotNil is a Checker checking that the provided value is not nil. IsNotNil is the equivalent of qt.Not(qt.IsNil) For instance: IsTrue checks that the provided value is true. The value must have a boolean underlying type. For instance: JSONEquals checks whether a byte slice or string is JSON-equivalent to a Go value. See CodecEquals for more information. It uses DeepEquals to do the comparison. If a more sophisticated comparison is required, use CodecEquals directly. For instance: Matches checks that a string or result of calling the String method (if the value implements fmt.Stringer) matches the provided regular expression. For instance: Not returns a Checker negating the given Checker. For instance: PanicMatches checks that the provided function panics with a message matching the provided regular expression. For instance: Satisfies checks that the provided value, when used as argument of the provided predicate function, causes the function to return true. The function must be of type func(T) bool, having got assignable to T. For instance: The testing.TB.Cleanup helper provides the ability to defer the execution of functions that will be run when the test completes. This is often useful for creating OS-level resources such as temporary directories (see c.Mkdir). When targeting Go versions that don't have Cleanup (< 1.14), the same can be achieved using c.Defer. In this case, to trigger the deferred behavior, calling c.Done is required. For instance, if you create a *C instance at the top level, you’ll have to add a defer to trigger the cleanups at the end of the test: However, if you use quicktest to create a subtest, Done will be called automatically at the end of that subtest. For example: The c.Patch, c.Setenv, c.Unsetenv and c.Mkdir helpers use t.Cleanup for cleaning up resources when available, and fall back to Defer otherwise.
40 versions
Latest release: almost 2 years ago
4,084 dependent packages

View more package details: https://packages.ecosystem.code.gouv.fr/registries/proxy.golang.org/packages/github.com/frankban/quicktest

Dependent Repos 14

rferrand/go-config-files-utils
Go library providing various helpers to work with configuration files

Last synced: about 1 year ago - Pushed: 11 months ago

1024pix/steampipe-plugin-learningcontent
Steampipe plugin to query LCMS content

Size: 101 KB - Last synced: 4 days ago - Pushed: over 1 year ago

1024pix/steampipe-plugin-metabase
Use SQL to query databases, tables, permissions and more from Metabase

Size: 1.22 MB - Last synced: 4 days ago - Pushed: 4 days ago

swh/infra/ci-cd/3rdparty/cert-manager-webhook-gandi

Last synced: 7 months ago - Pushed: 11 months ago

radiofrance/dib
An opinionated docker image builder

Size: 3.6 MB - Last synced: about 2 hours ago - Pushed: about 2 hours ago

radiofrance/image-registry-metrics-exporter
Image Registry Metrics Exporter provides metrics about creation and uploading time of images on OCI registry.

Size: 302 KB - Last synced: about 2 hours ago - Pushed: 8 days ago

betagouv/vouch-proxy Fork of vouch/vouch-proxy
an SSO and OAuth / OIDC login solution for Nginx using the auth_request module

Size: 5.68 MB - Last synced: 31 minutes ago - Pushed: over 1 year ago

signaux-faibles/opensignauxfaibles Fork of entrepreneur-interet-general/opensignauxfaibles
Plateforme de détection des entreprises fragiles

Size: 36.6 MB - Last synced: about 6 hours ago - Pushed: 3 months ago

signaux-faibles/IamUpdater
keycloakUpdater pour Signaux-Faibles

Size: 615 KB - Last synced: about 6 hours ago - Pushed: 11 months ago

signaux-faibles/datapi
datAPI - API des applications web signaux-faibles

Size: 43.1 MB - Last synced: about 6 hours ago - Pushed: about 12 hours ago

signaux-faibles/prepare-import
📥 Scripts de préparation à l'importation de données dans le processus d'intégration

Size: 276 KB - Last synced: about 6 hours ago - Pushed: 4 months ago

radiofrance/helm-chart-sonarqube Fork of SonarSource/helm-chart-sonarqube

Size: 2.99 MB - Last synced: 7 months ago - Pushed: 9 months ago

web-et-numerique/factory/llle_project/cozy-stack
Fork of cozy-stack https://github.com/cozy/cozy-stack

Last synced: 7 months ago

avirm/analysis-go

Last synced: 7 months ago - Pushed: 11 months ago

SocialGouv/sealed-secrets Fork of bitnami-labs/sealed-secrets
A Kubernetes controller and tool for one-way encrypted Secrets

Size: 39.6 MB - Last synced: 6 days ago - Pushed: 6 months ago

InseeFrLab/gonyxia-api

Size: 98.6 KB - Last synced: about 2 hours ago - Pushed: 9 days ago

InseeFrLab/onyxia-onboarding
Onboarding for the Onyxia datalab

Size: 68.4 KB - Last synced: about 2 hours ago - Pushed: over 1 year ago

SocialGouv/oblik
An operator designed to watch VPA objects and apply resources recommendations to Deployments and StatefulSets based on configurable annotations

Size: 9.01 MB - Last synced: 6 days ago - Pushed: 10 days ago

CEREMA/k3s-snapshots

Size: 6.12 MB - Last synced: 2 days ago - Pushed: almost 3 years ago

CEREMA/k3-utils

Size: 6.15 MB - Last synced: 2 days ago - Pushed: almost 3 years ago