tests

package
v1.72.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package tests serves a list of tests for tailscale.com/cmd/viewer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicType added in v1.70.0

type BasicType interface {
	~bool | constraints.Integer | constraints.Float | constraints.Complex | ~string
}

type Container added in v1.72.0

type Container[T any] struct {
	Item T
}

Container is a pre-defined container type, such as a collection, an optional value or a generic wrapper.

func (*Container[T]) Clone added in v1.72.0

func (c *Container[T]) Clone() *Container[T]

type ContainerView added in v1.72.0

type ContainerView[T views.ViewCloner[T, V], V views.StructView[T]] struct {
	// contains filtered or unexported fields
}

ContainerView is a pre-defined readonly view of a Container[T].

func ContainerViewOf added in v1.72.0

func ContainerViewOf[T views.ViewCloner[T, V], V views.StructView[T]](c *Container[T]) ContainerView[T, V]

func (ContainerView[T, V]) Item added in v1.72.0

func (cv ContainerView[T, V]) Item() V

type GenericBasicStruct added in v1.72.0

type GenericBasicStruct[T BasicType] struct {
	Value T
}

type GenericCloneableStruct added in v1.70.0

type GenericCloneableStruct[T views.ViewCloner[T, V], V views.StructView[T]] struct {
	Value T
	Slice []T
	Map   map[string]T

	// Unsupported views.
	Pointer     *T
	PtrSlice    []*T
	PtrKeyMap   map[*T]string `json:"-"`
	PtrValueMap map[string]*T
	SliceMap    map[string][]T
}

func (*GenericCloneableStruct[T, V]) Clone added in v1.70.0

func (src *GenericCloneableStruct[T, V]) Clone() *GenericCloneableStruct[T, V]

Clone makes a deep copy of GenericCloneableStruct. The result aliases no memory with the original.

func (*GenericCloneableStruct[T, V]) View added in v1.70.0

func (p *GenericCloneableStruct[T, V]) View() GenericCloneableStructView[T, V]

View returns a readonly view of GenericCloneableStruct.

type GenericCloneableStructView added in v1.70.0

type GenericCloneableStructView[T views.ViewCloner[T, V], V views.StructView[T]] struct {
	// contains filtered or unexported fields
}

GenericCloneableStructView[T, V] provides a read-only view over GenericCloneableStruct[T, V].

Its methods should only be called if `Valid()` returns true.

func (GenericCloneableStructView[T, V]) AsStruct added in v1.70.0

func (v GenericCloneableStructView[T, V]) AsStruct() *GenericCloneableStruct[T, V]

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (GenericCloneableStructView[T, V]) Map added in v1.70.0

func (v GenericCloneableStructView[T, V]) Map() views.MapFn[string, T, V]

func (GenericCloneableStructView[T, V]) MarshalJSON added in v1.70.0

func (v GenericCloneableStructView[T, V]) MarshalJSON() ([]byte, error)

func (GenericCloneableStructView[T, V]) Pointer added in v1.70.0

func (v GenericCloneableStructView[T, V]) Pointer() map[string]T

func (GenericCloneableStructView[T, V]) PtrKeyMap added in v1.70.0

func (v GenericCloneableStructView[T, V]) PtrKeyMap() map[*T]string

func (GenericCloneableStructView[T, V]) PtrSlice added in v1.70.0

func (v GenericCloneableStructView[T, V]) PtrSlice() *T

func (GenericCloneableStructView[T, V]) PtrValueMap added in v1.70.0

func (v GenericCloneableStructView[T, V]) PtrValueMap() map[string]*T

func (GenericCloneableStructView[T, V]) Slice added in v1.70.0

func (v GenericCloneableStructView[T, V]) Slice() views.SliceView[T, V]

func (GenericCloneableStructView[T, V]) SliceMap added in v1.70.0

func (v GenericCloneableStructView[T, V]) SliceMap() map[string][]T

func (*GenericCloneableStructView[T, V]) UnmarshalJSON added in v1.70.0

func (v *GenericCloneableStructView[T, V]) UnmarshalJSON(b []byte) error

func (GenericCloneableStructView[T, V]) Valid added in v1.70.0

func (v GenericCloneableStructView[T, V]) Valid() bool

Valid reports whether underlying value is non-nil.

func (GenericCloneableStructView[T, V]) Value added in v1.70.0

func (v GenericCloneableStructView[T, V]) Value() V

type GenericIntStruct added in v1.70.0

type GenericIntStruct[T constraints.Integer] struct {
	Value   T
	Pointer *T
	Slice   []T
	Map     map[string]T

	// Unsupported views.
	PtrSlice    []*T
	PtrKeyMap   map[*T]string `json:"-"`
	PtrValueMap map[string]*T
	SliceMap    map[string][]T
}

func (*GenericIntStruct[T]) Clone added in v1.70.0

func (src *GenericIntStruct[T]) Clone() *GenericIntStruct[T]

Clone makes a deep copy of GenericIntStruct. The result aliases no memory with the original.

func (*GenericIntStruct[T]) View added in v1.70.0

func (p *GenericIntStruct[T]) View() GenericIntStructView[T]

View returns a readonly view of GenericIntStruct.

type GenericIntStructView added in v1.70.0

type GenericIntStructView[T constraints.Integer] struct {
	// contains filtered or unexported fields
}

GenericIntStructView[T] provides a read-only view over GenericIntStruct[T].

Its methods should only be called if `Valid()` returns true.

func (GenericIntStructView[T]) AsStruct added in v1.70.0

func (v GenericIntStructView[T]) AsStruct() *GenericIntStruct[T]

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (GenericIntStructView[T]) Map added in v1.70.0

func (v GenericIntStructView[T]) Map() views.Map[string, T]

func (GenericIntStructView[T]) MarshalJSON added in v1.70.0

func (v GenericIntStructView[T]) MarshalJSON() ([]byte, error)

func (GenericIntStructView[T]) Pointer added in v1.70.0

func (v GenericIntStructView[T]) Pointer() *T

func (GenericIntStructView[T]) PtrKeyMap added in v1.70.0

func (v GenericIntStructView[T]) PtrKeyMap() map[*T]string

func (GenericIntStructView[T]) PtrSlice added in v1.70.0

func (v GenericIntStructView[T]) PtrSlice() *T

func (GenericIntStructView[T]) PtrValueMap added in v1.70.0

func (v GenericIntStructView[T]) PtrValueMap() map[string]*T

func (GenericIntStructView[T]) Slice added in v1.70.0

func (v GenericIntStructView[T]) Slice() views.Slice[T]

func (GenericIntStructView[T]) SliceMap added in v1.70.0

func (v GenericIntStructView[T]) SliceMap() map[string][]T

func (*GenericIntStructView[T]) UnmarshalJSON added in v1.70.0

func (v *GenericIntStructView[T]) UnmarshalJSON(b []byte) error

func (GenericIntStructView[T]) Valid added in v1.70.0

func (v GenericIntStructView[T]) Valid() bool

Valid reports whether underlying value is non-nil.

func (GenericIntStructView[T]) Value added in v1.70.0

func (v GenericIntStructView[T]) Value() T

type GenericNoPtrsStruct added in v1.70.0

type GenericNoPtrsStruct[T StructWithoutPtrs | netip.Prefix | BasicType] struct {
	Value   T
	Pointer *T
	Slice   []T
	Map     map[string]T

	// Unsupported views.
	PtrSlice    []*T
	PtrKeyMap   map[*T]string `json:"-"`
	PtrValueMap map[string]*T
	SliceMap    map[string][]T
}

func (*GenericNoPtrsStruct[T]) Clone added in v1.70.0

func (src *GenericNoPtrsStruct[T]) Clone() *GenericNoPtrsStruct[T]

Clone makes a deep copy of GenericNoPtrsStruct. The result aliases no memory with the original.

func (*GenericNoPtrsStruct[T]) View added in v1.70.0

View returns a readonly view of GenericNoPtrsStruct.

type GenericNoPtrsStructView added in v1.70.0

type GenericNoPtrsStructView[T StructWithoutPtrs | netip.Prefix | BasicType] struct {
	// contains filtered or unexported fields
}

GenericNoPtrsStructView[T] provides a read-only view over GenericNoPtrsStruct[T].

Its methods should only be called if `Valid()` returns true.

func (GenericNoPtrsStructView[T]) AsStruct added in v1.70.0

func (v GenericNoPtrsStructView[T]) AsStruct() *GenericNoPtrsStruct[T]

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (GenericNoPtrsStructView[T]) Map added in v1.70.0

func (v GenericNoPtrsStructView[T]) Map() views.Map[string, T]

func (GenericNoPtrsStructView[T]) MarshalJSON added in v1.70.0

func (v GenericNoPtrsStructView[T]) MarshalJSON() ([]byte, error)

func (GenericNoPtrsStructView[T]) Pointer added in v1.70.0

func (v GenericNoPtrsStructView[T]) Pointer() *T

func (GenericNoPtrsStructView[T]) PtrKeyMap added in v1.70.0

func (v GenericNoPtrsStructView[T]) PtrKeyMap() map[*T]string

func (GenericNoPtrsStructView[T]) PtrSlice added in v1.70.0

func (v GenericNoPtrsStructView[T]) PtrSlice() *T

func (GenericNoPtrsStructView[T]) PtrValueMap added in v1.70.0

func (v GenericNoPtrsStructView[T]) PtrValueMap() map[string]*T

func (GenericNoPtrsStructView[T]) Slice added in v1.70.0

func (v GenericNoPtrsStructView[T]) Slice() views.Slice[T]

func (GenericNoPtrsStructView[T]) SliceMap added in v1.70.0

func (v GenericNoPtrsStructView[T]) SliceMap() map[string][]T

func (*GenericNoPtrsStructView[T]) UnmarshalJSON added in v1.70.0

func (v *GenericNoPtrsStructView[T]) UnmarshalJSON(b []byte) error

func (GenericNoPtrsStructView[T]) Valid added in v1.70.0

func (v GenericNoPtrsStructView[T]) Valid() bool

Valid reports whether underlying value is non-nil.

func (GenericNoPtrsStructView[T]) Value added in v1.70.0

func (v GenericNoPtrsStructView[T]) Value() T

type Map

type Map struct {
	Int                 map[string]int
	SliceInt            map[string][]int
	StructPtrWithPtr    map[string]*StructWithPtrs
	StructPtrWithoutPtr map[string]*StructWithoutPtrs
	StructWithoutPtr    map[string]StructWithoutPtrs
	SlicesWithPtrs      map[string][]*StructWithPtrs
	SlicesWithoutPtrs   map[string][]*StructWithoutPtrs
	StructWithoutPtrKey map[StructWithoutPtrs]int `json:"-"`
	StructWithPtr       map[string]StructWithPtrs

	// Unsupported views.
	SliceIntPtr      map[string][]*int
	PointerKey       map[*string]int        `json:"-"`
	StructWithPtrKey map[StructWithPtrs]int `json:"-"`
}

func (*Map) Clone

func (src *Map) Clone() *Map

Clone makes a deep copy of Map. The result aliases no memory with the original.

func (*Map) View

func (p *Map) View() MapView

View returns a readonly view of Map.

type MapContainer added in v1.72.0

type MapContainer[K comparable, V views.Cloner[V]] struct {
	Items map[K]V
}

MapContainer is a predefined map-like container type. Unlike Container, it has two type parameters, where the value is the second parameter.

func (*MapContainer[K, V]) Clone added in v1.72.0

func (c *MapContainer[K, V]) Clone() *MapContainer[K, V]

type MapContainerView added in v1.72.0

type MapContainerView[K comparable, T views.ViewCloner[T, V], V views.StructView[T]] struct {
	// contains filtered or unexported fields
}

MapContainerView is a pre-defined readonly view of a MapContainer[K, T].

func MapContainerViewOf added in v1.72.0

func MapContainerViewOf[K comparable, T views.ViewCloner[T, V], V views.StructView[T]](c *MapContainer[K, T]) MapContainerView[K, T, V]

func (MapContainerView[K, T, V]) Items added in v1.72.0

func (cv MapContainerView[K, T, V]) Items() views.MapFn[K, T, V]

type MapView

type MapView struct {
	// contains filtered or unexported fields
}

MapView provides a read-only view over Map.

Its methods should only be called if `Valid()` returns true.

func (MapView) AsStruct

func (v MapView) AsStruct() *Map

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (MapView) Int

func (v MapView) Int() views.Map[string, int]

func (MapView) MarshalJSON

func (v MapView) MarshalJSON() ([]byte, error)

func (MapView) PointerKey

func (v MapView) PointerKey() map[*string]int

func (MapView) SliceInt

func (v MapView) SliceInt() views.MapSlice[string, int]

func (MapView) SliceIntPtr

func (v MapView) SliceIntPtr() map[string][]*int

func (MapView) StructPtrWithPtr added in v1.30.0

func (v MapView) StructPtrWithPtr() views.MapFn[string, *StructWithPtrs, StructWithPtrsView]

func (MapView) StructPtrWithoutPtr added in v1.30.0

func (v MapView) StructPtrWithoutPtr() views.MapFn[string, *StructWithoutPtrs, StructWithoutPtrsView]

func (MapView) StructWithPtr

func (MapView) StructWithPtrKey

func (v MapView) StructWithPtrKey() map[StructWithPtrs]int

func (MapView) StructWithoutPtr

func (v MapView) StructWithoutPtr() views.Map[string, StructWithoutPtrs]

func (MapView) StructWithoutPtrKey

func (v MapView) StructWithoutPtrKey() views.Map[StructWithoutPtrs, int]

func (*MapView) UnmarshalJSON

func (v *MapView) UnmarshalJSON(b []byte) error

func (MapView) Valid

func (v MapView) Valid() bool

Valid reports whether underlying value is non-nil.

type OnlyGetClone added in v1.30.0

type OnlyGetClone struct {
	SinViewerPorFavor bool
}

func (*OnlyGetClone) Clone added in v1.30.0

func (src *OnlyGetClone) Clone() *OnlyGetClone

Clone makes a deep copy of OnlyGetClone. The result aliases no memory with the original.

type StructWithContainers added in v1.72.0

type StructWithContainers struct {
	IntContainer              Container[int]
	CloneableContainer        Container[*StructWithPtrs]
	BasicGenericContainer     Container[GenericBasicStruct[int]]
	CloneableGenericContainer Container[*GenericNoPtrsStruct[int]]
	CloneableMap              MapContainer[int, *StructWithPtrs]
	CloneableGenericMap       MapContainer[int, *GenericNoPtrsStruct[int]]
}

func (*StructWithContainers) Clone added in v1.72.0

Clone makes a deep copy of StructWithContainers. The result aliases no memory with the original.

func (*StructWithContainers) View added in v1.72.0

View returns a readonly view of StructWithContainers.

type StructWithContainersView added in v1.72.0

type StructWithContainersView struct {
	// contains filtered or unexported fields
}

StructWithContainersView provides a read-only view over StructWithContainers.

Its methods should only be called if `Valid()` returns true.

func (StructWithContainersView) AsStruct added in v1.72.0

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithContainersView) BasicGenericContainer added in v1.72.0

func (v StructWithContainersView) BasicGenericContainer() Container[GenericBasicStruct[int]]

func (StructWithContainersView) CloneableContainer added in v1.72.0

func (StructWithContainersView) CloneableGenericContainer added in v1.72.0

func (StructWithContainersView) CloneableGenericMap added in v1.72.0

func (StructWithContainersView) CloneableMap added in v1.72.0

func (StructWithContainersView) IntContainer added in v1.72.0

func (v StructWithContainersView) IntContainer() Container[int]

func (StructWithContainersView) MarshalJSON added in v1.72.0

func (v StructWithContainersView) MarshalJSON() ([]byte, error)

func (*StructWithContainersView) UnmarshalJSON added in v1.72.0

func (v *StructWithContainersView) UnmarshalJSON(b []byte) error

func (StructWithContainersView) Valid added in v1.72.0

func (v StructWithContainersView) Valid() bool

Valid reports whether underlying value is non-nil.

type StructWithEmbedded added in v1.42.0

type StructWithEmbedded struct {
	A *StructWithPtrs
	StructWithSlices
}

func (*StructWithEmbedded) Clone added in v1.42.0

func (src *StructWithEmbedded) Clone() *StructWithEmbedded

Clone makes a deep copy of StructWithEmbedded. The result aliases no memory with the original.

func (*StructWithEmbedded) View added in v1.42.0

View returns a readonly view of StructWithEmbedded.

type StructWithEmbeddedView added in v1.42.0

type StructWithEmbeddedView struct {
	// contains filtered or unexported fields
}

StructWithEmbeddedView provides a read-only view over StructWithEmbedded.

Its methods should only be called if `Valid()` returns true.

func (StructWithEmbeddedView) A added in v1.42.0

func (StructWithEmbeddedView) AsStruct added in v1.42.0

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithEmbeddedView) MarshalJSON added in v1.42.0

func (v StructWithEmbeddedView) MarshalJSON() ([]byte, error)

func (StructWithEmbeddedView) StructWithSlices added in v1.42.0

func (v StructWithEmbeddedView) StructWithSlices() StructWithSlicesView

func (*StructWithEmbeddedView) UnmarshalJSON added in v1.42.0

func (v *StructWithEmbeddedView) UnmarshalJSON(b []byte) error

func (StructWithEmbeddedView) Valid added in v1.42.0

func (v StructWithEmbeddedView) Valid() bool

Valid reports whether underlying value is non-nil.

type StructWithPtrs

type StructWithPtrs struct {
	Value *StructWithoutPtrs
	Int   *int

	NoCloneValue *StructWithoutPtrs `codegen:"noclone"`
}

func (*StructWithPtrs) Clone

func (src *StructWithPtrs) Clone() *StructWithPtrs

Clone makes a deep copy of StructWithPtrs. The result aliases no memory with the original.

func (*StructWithPtrs) Equal

func (v *StructWithPtrs) Equal(v2 *StructWithPtrs) bool

func (*StructWithPtrs) String

func (v *StructWithPtrs) String() string

func (*StructWithPtrs) View

View returns a readonly view of StructWithPtrs.

type StructWithPtrsView

type StructWithPtrsView struct {
	// contains filtered or unexported fields
}

StructWithPtrsView provides a read-only view over StructWithPtrs.

Its methods should only be called if `Valid()` returns true.

func (StructWithPtrsView) AsStruct

func (v StructWithPtrsView) AsStruct() *StructWithPtrs

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithPtrsView) Equal

func (StructWithPtrsView) Int

func (v StructWithPtrsView) Int() *int

func (StructWithPtrsView) MarshalJSON

func (v StructWithPtrsView) MarshalJSON() ([]byte, error)

func (StructWithPtrsView) NoCloneValue

func (v StructWithPtrsView) NoCloneValue() *StructWithoutPtrs

func (StructWithPtrsView) String

func (v StructWithPtrsView) String() string

func (*StructWithPtrsView) UnmarshalJSON

func (v *StructWithPtrsView) UnmarshalJSON(b []byte) error

func (StructWithPtrsView) Valid

func (v StructWithPtrsView) Valid() bool

Valid reports whether underlying value is non-nil.

func (StructWithPtrsView) Value

type StructWithSlices

type StructWithSlices struct {
	Values         []StructWithoutPtrs
	ValuePointers  []*StructWithoutPtrs
	StructPointers []*StructWithPtrs

	Slice    []string
	Prefixes []netip.Prefix
	Data     []byte

	// Unsupported views.
	Structs []StructWithPtrs
	Ints    []*int
}

func (*StructWithSlices) Clone

func (src *StructWithSlices) Clone() *StructWithSlices

Clone makes a deep copy of StructWithSlices. The result aliases no memory with the original.

func (*StructWithSlices) View

View returns a readonly view of StructWithSlices.

type StructWithSlicesView

type StructWithSlicesView struct {
	// contains filtered or unexported fields
}

StructWithSlicesView provides a read-only view over StructWithSlices.

Its methods should only be called if `Valid()` returns true.

func (StructWithSlicesView) AsStruct

func (v StructWithSlicesView) AsStruct() *StructWithSlices

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithSlicesView) Data

func (StructWithSlicesView) Ints

func (v StructWithSlicesView) Ints() *int

func (StructWithSlicesView) MarshalJSON

func (v StructWithSlicesView) MarshalJSON() ([]byte, error)

func (StructWithSlicesView) Prefixes

func (StructWithSlicesView) Slice

func (StructWithSlicesView) StructPointers

func (StructWithSlicesView) Structs

func (*StructWithSlicesView) UnmarshalJSON

func (v *StructWithSlicesView) UnmarshalJSON(b []byte) error

func (StructWithSlicesView) Valid

func (v StructWithSlicesView) Valid() bool

Valid reports whether underlying value is non-nil.

func (StructWithSlicesView) ValuePointers

func (StructWithSlicesView) Values

type StructWithoutPtrs

type StructWithoutPtrs struct {
	Int int
	Pfx netip.Prefix
}

func (*StructWithoutPtrs) Clone

func (src *StructWithoutPtrs) Clone() *StructWithoutPtrs

Clone makes a deep copy of StructWithoutPtrs. The result aliases no memory with the original.

func (*StructWithoutPtrs) View

View returns a readonly view of StructWithoutPtrs.

type StructWithoutPtrsView

type StructWithoutPtrsView struct {
	// contains filtered or unexported fields
}

StructWithoutPtrsView provides a read-only view over StructWithoutPtrs.

Its methods should only be called if `Valid()` returns true.

func (StructWithoutPtrsView) AsStruct

AsStruct returns a clone of the underlying value which aliases no memory with the original.

func (StructWithoutPtrsView) Int

func (v StructWithoutPtrsView) Int() int

func (StructWithoutPtrsView) MarshalJSON

func (v StructWithoutPtrsView) MarshalJSON() ([]byte, error)

func (StructWithoutPtrsView) Pfx

func (*StructWithoutPtrsView) UnmarshalJSON

func (v *StructWithoutPtrsView) UnmarshalJSON(b []byte) error

func (StructWithoutPtrsView) Valid

func (v StructWithoutPtrsView) Valid() bool

Valid reports whether underlying value is non-nil.

Jump to

Keyboard shortcuts

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