report

package
v1.1.16 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Enum to json.UnmarshalJson and json.MarshalJSON taken from: https://gist.github.com/lummie/7f5c237a17853c031a57277371528e87 We might be able to use https://github.com/campoy/jsonenums - might do this after the package is tested.

Enum to json.UnmarshalJson and json.MarshalJSON taken from: https://gist.github.com/lummie/7f5c237a17853c031a57277371528e87 We might be able to use https://github.com/campoy/jsonenums - might do this after the package is tested.

Index

Constants

View Source
const (
	// Version - version of the `Report`.
	// TODO(mbana): probably need a better way of getting/setting the version of the Report Exporter
	Version = "0.0.1"
)

Variables

This section is empty.

Functions

func GetFails added in v1.1.9

func GetFails(specs map[results.ResultKey][]results.TestCase) int

GetFails - fails is the number of specification tests that failed, it is not the number of failed tests.

Types

type APISpecification added in v1.1.6

type APISpecification struct {
	Name    string             `json:"name"`
	Version string             `json:"version"`
	Results []results.TestCase `json:"results"`
}

type CertifiedBy added in v1.1.0

type CertifiedBy struct {
	Environment  CertifiedByEnvironment `json:"environment"`  // Name of the environment tested
	Brand        string                 `json:"brand"`        // Name of the brand tested
	AuthorisedBy string                 `json:"authorisedBy"` // Name of the Authoriser
	JobTitle     string                 `json:"jobTitle"`     // Job Title of the Authorisee
}

CertifiedBy - contains details of who certified the `Report`.

func (CertifiedBy) Validate added in v1.1.0

func (r CertifiedBy) Validate() error

Validate - called by `github.com/go-ozzo/ozzo-validation` to validate struct.

type CertifiedByEnvironment added in v1.1.0

type CertifiedByEnvironment int

CertifiedByEnvironment - the environment the `Report` was generated in.

const (
	// ReportCertifiedByEnvironmentTesting - testing environment.
	CertifiedByEnvironmentTesting CertifiedByEnvironment = iota + 1
	// ReportCertifiedByEnvironmentProduction - production environment.
	CertifiedByEnvironmentProduction
	CertifiedByEnvironmentSandbox
)

func (CertifiedByEnvironment) MarshalJSON added in v1.1.0

func (r CertifiedByEnvironment) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (CertifiedByEnvironment) String added in v1.1.0

func (r CertifiedByEnvironment) String() string

func (*CertifiedByEnvironment) UnmarshalJSON added in v1.1.0

func (r *CertifiedByEnvironment) UnmarshalJSON(data []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type Exporter

type Exporter interface {
	Export() error
}

Exporter - allows the exporting of a `Report`.

func NewZipExporter

func NewZipExporter(report Report, writer io.Writer) Exporter

NewZipExporter - return new `Exporter` that exports to a ZIP archive to `writer`. The caller should close `writer` after calling `Export`.

For example:

writer, err := os.Create("report.zip")
defer writer.Close()
exporter := NewZipExporter(Report{}, writer)
exporter.Export()

type Importer added in v1.1.0

type Importer interface {
	Import() (Report, error)
}

Importer - allows the importing of a `Report`.

func NewZipImporter added in v1.1.0

func NewZipImporter(reader io.Reader) Importer

NewZipImporter - return new `Importer` that allows importing from a ZIP archive.

type Report

type Report struct {
	ID               string             `json:"id"`                       // A unique and immutable identifier used to identify the report. The v4 UUIDs generated conform to RFC 4122.
	Created          string             `json:"created"`                  // Date and time when the report was created, formatted accorrding to RFC3339 (https://tools.ietf.org/html/rfc3339). Note RFC3339 is derived from ISO 8601 (https://en.wikipedia.org/wiki/ISO_8601).
	Expiration       *string            `json:"expiration,omitempty"`     // Date and time when the report should not longer be accepted, formatted accorrding to RFC3339 (https://tools.ietf.org/html/rfc3339). Note RFC3339 is derived from ISO 8601 (https://en.wikipedia.org/wiki/ISO_8601).
	Fails            int                `json:"fails"`                    // Calculates *total* failures across the whole report, accumulated for each specification.
	Version          string             `json:"version"`                  // The current version of the report model used.
	Status           Status             `json:"status"`                   // A status describing overall condition of the report.
	CertifiedBy      CertifiedBy        `json:"certifiedBy"`              // The certifier of the report.
	SignatureChain   *[]SignatureChain  `json:"signatureChain,omitempty"` // When Add digital signature is set this contains the signature chain.
	Discovery        discovery.Model    `json:"-"`                        // Original used discovery model
	APISpecification []APISpecification `json:"apiSpecification"`         // API and version tested, along with test cases
	FCSVersion       string             `json:"fcsVersion"`               // Version of FCS running the tests
}

Report - The Report.

func NewReport

func NewReport(exportResults models.ExportResults, environment string) (Report, error)

NewReport - create `Report` from `ExportResults`.

func (Report) Validate

func (r Report) Validate() error

Validate - called by `github.com/go-ozzo/ozzo-validation` to validate struct.

type SignatureChain added in v1.1.0

type SignatureChain struct {
	Type    string `json:"type"`
	Creator string `json:"creator"`
	Domain  string `json:"domain"`
	Nounce  string `json:"nounce"`
	Value   string `json:"value"`
}

SignatureChain -

type Status added in v1.1.0

type Status int

Status - the status of the `Report`.

const (
	// StatusPending - The `Report` is pending.
	StatusPending Status = iota + 1
	// StatusComplete - The `Report` is complete.
	StatusComplete
	// StatusError - The `Report` is in error.
	StatusError
)

func (Status) MarshalJSON added in v1.1.0

func (r Status) MarshalJSON() ([]byte, error)

MarshalJSON - marshals the enum as a quoted json string

func (Status) String added in v1.1.0

func (r Status) String() string

func (*Status) UnmarshalJSON added in v1.1.0

func (r *Status) UnmarshalJSON(data []byte) error

UnmarshalJSON - unmashals a quoted json string to the enum value

Jump to

Keyboard shortcuts

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