boottest

package
v7.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package boottest contains methods for comparing boot.OSImages to each other and to JSON representations of themselves for use in tests.

The JSON representation for boot.OSImages is special because the built-in json.Marshal function cannot marshal interfaces such as io.ReaderAt nicely, especially when the underlying members in structs used (such as *os.File or curl.lazyFile) are not exported.

They are not json.Marshalers as part of boot.OSImage itself because they're not a fully accurate representation of an OSImage, not including file contents and depending for example on the current working directory of the calling process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareImagesToJSON

func CompareImagesToJSON(imgs []boot.OSImage, jsonEncoded []byte) error

CompareImagesToJSON compares the names, cmdlines, and file URLs in imgs to the ones stored in jsonEncoded.

You can obtain such a JSON encoding with ToJSONFile.

func ImagesToJSONLike

func ImagesToJSONLike(imgs []boot.OSImage) []interface{}

ImagesToJSONLike spits out a json-convertible reproducible representation of the given boot images. This can be used in configuration parser tests (when the content of the images doesn't matter, but the file URLs, cmdlines, names, etc.)

The JSON representation for boot.OSImages is special because the built-in json.Marshal function cannot marshal interfaces such as io.ReaderAt nicely, especially when the underlying structs used are not exported.

func LinuxImageToJSON

func LinuxImageToJSON(li *boot.LinuxImage) map[string]interface{}

LinuxImageToJSON is implemented only in order to compare LinuxImages in tests.

It should be json-encodable and decodable.

func MultibootImageToJSON

func MultibootImageToJSON(mi *boot.MultibootImage) map[string]interface{}

MultibootImageToJSON is implemented only in order to compare MultibootImages in tests.

It should be json-encodable and decodable.

func SameBootImage

func SameBootImage(got, want boot.OSImage) error

SameBootImage compares the contents of given boot images, but not the underlying URLs.

Works for Linux and Multiboot images.

func ToJSONFile

func ToJSONFile(imgs []boot.OSImage, filename string) error

ToJSONFile can be used to generate JSON-comparable files for use with CompareImagesToJSON in tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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