gcsv

package module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2021 License: MIT Imports: 6 Imported by: 0

README

Go Report Card Go Build

Gomega matchers for CSV Schema

This package provides Gomega matchers to write assertions against Schema of a CSV:

RepresentSchema()

Verifies that an entire CSV matches the actual schema of an []interface{} array made up of the following basic types:

  • int
  • bool
  • float64
  • string

Note: Values for the actual schema are representative only and don't mean anything in and of themselves, they are just used for switching on type

import (
  . "github.com/mikfreedman/gcsv"
)

Expect("a,b,c,1,2,3").To(RepresentSchema([]interface{"a","b","c",1,2,3})) // Pass
Expect("a,b,c,d,e,f").To(RepresentSchema([]interface{"a","b","c",1,2,3})) // Fail!

Expect("header1,header2,header3,header4,header5,header6\na,b,c,d,e,f").
  To(RepresentSchema([]interface{"a","b","c",1,2,3}, IgnoreHeaderRow())) // Pass

Expect("header1,header2,header3,header4,header5,header6\na,b,c,d,e,f").
  To(RepresentSchema([]interface{"a","b","c",1,2,3}, WithHeaders("jeepers", "creepers"))) // Fail!


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RepresentSchema

func RepresentSchema(expected []interface{}, opts ...RepresentSchemaOption) types.GomegaMatcher

Types

type RepresentSchemaOption

type RepresentSchemaOption func(*representSchemaMatcher)

func IgnoreHeaderRow

func IgnoreHeaderRow() RepresentSchemaOption

func WithHeaders added in v0.0.3

func WithHeaders(headers ...string) RepresentSchemaOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL