diff --git a/Makefile b/Makefile index d4318061..2256a929 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # # MIT License # -# (C) Copyright 2021-2023 Hewlett Packard Enterprise Development LP +# (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), @@ -185,6 +185,19 @@ bin/swagger-codegen-cli.jar: mkdir -p ./bin wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.43/swagger-codegen-cli-3.0.43.jar -O bin/swagger-codegen-cli.jar +# needs human munging until go-jsonschema can read a dir for resolving refs +netbox-dt-schema: + go-jsonschema -p netbox devicetype-library/schema/devicetype.json -o pkg/netbox/types_devicetypes.go + +# needs human munging until go-jsonschema can read a dir for resolving refs +netbox-mt-schema: + go-jsonschema -p netbox devicetype-library/schema/moduletype.json -o pkg/netbox/types_moduletypes.go + +# needs human munging find/replace to make the generated file work +nbschema: netbox-dt-schema netbox-mt-schema + go-jsonschema -p netbox pkg/netbox/schema/devicetype-for-go-jsonschema.json -o pkg/netbox/types_devicetypes.go + go-jsonschema -p netbox pkg/netbox/schema/moduletype-for-go-jsonschema.json -o pkg/netbox/types_moduletypes.go + vet: version go vet -v ./... diff --git a/go.mod b/go.mod index 785ad99f..c6646b77 100644 --- a/go.mod +++ b/go.mod @@ -12,11 +12,12 @@ require ( github.com/hashicorp/go-retryablehttp v0.7.2 github.com/manifoldco/promptui v0.9.0 github.com/mitchellh/mapstructure v1.5.0 + github.com/netbox-community/go-netbox/v3 v3.7.1-alpha.0 github.com/rs/zerolog v1.29.1 github.com/santhosh-tekuri/jsonschema/v5 v5.3.0 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.7.1 + github.com/stretchr/testify v1.8.4 golang.org/x/oauth2 v0.8.0 golang.org/x/term v0.16.0 gopkg.in/ini.v1 v1.67.0 diff --git a/go.sum b/go.sum index a01e3103..b7d0efb6 100644 --- a/go.sum +++ b/go.sum @@ -275,6 +275,8 @@ github.com/mutecomm/go-sqlcipher/v4 v4.4.0/go.mod h1:PyN04SaWalavxRGH9E8ZftG6Ju7 github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8/go.mod h1:86wM1zFnC6/uDBfZGNwB65O+pR2OFi5q/YQaEUid1qA= github.com/namsral/flag v1.7.4-pre/go.mod h1:OXldTctbM6SWH1K899kPZcf65KxJiD7MsceFUpB5yDo= github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba/go.mod h1:ncO5VaFWh0Nrt+4KT4mOZboaczBZcLuHrG+/sUeP8gI= +github.com/netbox-community/go-netbox/v3 v3.7.1-alpha.0 h1:lh17EC7tIUMkD7Z9BO0TlbaHMzW5EWNqFjPu42IOtA8= +github.com/netbox-community/go-netbox/v3 v3.7.1-alpha.0/go.mod h1:RNFSP40YwfddVs1EJGTDcFwlHWp+Dv0+x7tNmrsnMTE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= @@ -324,8 +326,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/xanzy/go-gitlab v0.15.0/go.mod h1:8zdQa/ri1dfn8eS3Ir1SyfvOKlw7WBJ8DVThkpGiXrs= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= @@ -659,7 +661,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= diff --git a/pkg/netbox/netbox.go b/pkg/netbox/netbox.go new file mode 100644 index 00000000..9b0b70f2 --- /dev/null +++ b/pkg/netbox/netbox.go @@ -0,0 +1,76 @@ +/* + * + * MIT License + * + * (C) Copyright 2024 Hewlett Packard Enterprise Development LP + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ +package netbox + +import ( + "context" + "crypto/tls" + "fmt" + "net/http" + "os" + + "github.com/hashicorp/go-retryablehttp" + "github.com/netbox-community/go-netbox/v3" +) + +// NewClient creates a new netbox client using the environment variables +// This maintains parity/compatiblity with Device-Type-Librery-Import repo +// by using the same environment variables +func NewClient() (*netbox.APIClient, context.Context, error) { + // use the certificates in the http client + tlsConfig := &tls.Config{} + if os.Getenv("IGNORE_SSL_ERRORS") == "True" { + tlsConfig.InsecureSkipVerify = true + } else { + tlsConfig.InsecureSkipVerify = false + } + + // use TLS config in transport + tr := &http.Transport{ + TLSClientConfig: tlsConfig, + } + + // Setup our HTTP transport and client + httpClient := retryablehttp.NewClient() + httpClient.HTTPClient.Transport = tr + httpClient.Logger = nil + c := httpClient.StandardClient() + + // create the netbox config + token := os.Getenv("NETBOX_TOKEN") + host := stripProtocolsAndSpecialChars(os.Getenv("NETBOX_URL")) + nbcfg := netbox.NewConfiguration() + nbcfg.Host = host + nbcfg.HTTPClient = c + nbcfg.DefaultHeader["Authorization"] = fmt.Sprintf("Token %s", token) + nbcfg.Debug = false + nbcfg.Scheme = "https" + + ctx := context.Background() + client := netbox.NewAPIClient(nbcfg) + + return client, ctx, nil +} diff --git a/pkg/netbox/schema/devicetype-for-go-jsonschema.json b/pkg/netbox/schema/devicetype-for-go-jsonschema.json new file mode 100644 index 00000000..e44369f1 --- /dev/null +++ b/pkg/netbox/schema/devicetype-for-go-jsonschema.json @@ -0,0 +1,793 @@ +{ + "type": "object", + "properties": { + "manufacturer": { + "type": "string" + }, + "model": { + "type": "string" + }, + "slug": { + "type": "string", + "pattern": "^[-a-z0-9_]+$" + }, + "part_number": { + "type": "string" + }, + "u_height": { + "type": "number", + "minimum": 0, + "multipleOf": 0.5 + }, + "is_full_depth": { + "type": "boolean" + }, + "airflow": { + "type": "string", + "enum": [ + "front-to-rear", + "rear-to-front", + "left-to-right", + "right-to-left", + "side-to-rear", + "passive", + "mixed" + ] + }, + "weight": { + "type": "number", + "minimum": 0, + "multipleOf": 0.01 + }, + "weight_unit": { + "type": "string", + "enum": [ + "kg", + "g", + "lb", + "oz" + ] + }, + "front_image": { + "type": "boolean" + }, + "rear_image": { + "type": "boolean" + }, + "subdevice_role": { + "type": "string", + "enum": [ + "parent", + "child" + ] + }, + "is_powered": { + "type": "boolean" + }, + "console-ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "de-9", + "db-25", + "rj-11", + "rj-12", + "rj-45", + "mini-din-8", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "other" + ] + }, + "poe": { + "type": "boolean" + } + }, + "required": [ + "name", + "type" + ] + } + }, + "console-server-ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "de-9", + "db-25", + "rj-11", + "rj-12", + "rj-45", + "mini-din-8", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "other" + ] + } + }, + "required": [ + "name", + "type" + ] + } + }, + "power-ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "iec-60320-c6", + "iec-60320-c8", + "iec-60320-c14", + "iec-60320-c16", + "iec-60320-c20", + "iec-60320-c22", + "iec-60309-p-n-e-4h", + "iec-60309-p-n-e-6h", + "iec-60309-p-n-e-9h", + "iec-60309-2p-e-4h", + "iec-60309-2p-e-6h", + "iec-60309-2p-e-9h", + "iec-60309-3p-e-4h", + "iec-60309-3p-e-6h", + "iec-60309-3p-e-9h", + "iec-60309-3p-n-e-4h", + "iec-60309-3p-n-e-6h", + "iec-60309-3p-n-e-9h", + "iec-60906-1", + "nbr-14136-10a", + "nbr-14136-20a", + "nema-1-15p", + "nema-5-15p", + "nema-5-20p", + "nema-5-30p", + "nema-5-50p", + "nema-6-15p", + "nema-6-20p", + "nema-6-30p", + "nema-6-50p", + "nema-10-30p", + "nema-10-50p", + "nema-14-20p", + "nema-14-30p", + "nema-14-50p", + "nema-14-60p", + "nema-15-15p", + "nema-15-20p", + "nema-15-30p", + "nema-15-50p", + "nema-15-60p", + "nema-l1-15p", + "nema-l5-15p", + "nema-l5-20p", + "nema-l5-30p", + "nema-l5-50p", + "nema-l6-15p", + "nema-l6-20p", + "nema-l6-30p", + "nema-l6-50p", + "nema-l10-30p", + "nema-l14-20p", + "nema-l14-30p", + "nema-l14-50p", + "nema-l14-60p", + "nema-l15-20p", + "nema-l15-30p", + "nema-l15-50p", + "nema-l15-60p", + "nema-l21-20p", + "nema-l21-30p", + "nema-l22-30p", + "cs6361c", + "cs6365c", + "cs8165c", + "cs8265c", + "cs8365c", + "cs8465c", + "ita-c", + "ita-e", + "ita-f", + "ita-ef", + "ita-g", + "ita-h", + "ita-i", + "ita-j", + "ita-k", + "ita-l", + "ita-m", + "ita-n", + "ita-o", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "usb-3-b", + "usb-3-micro-b", + "dc-terminal", + "saf-d-grid", + "neutrik-powercon-20", + "neutrik-powercon-32", + "neutrik-powercon-true1", + "neutrik-powercon-true1-top", + "ubiquiti-smartpower", + "hardwired", + "other" + ] + }, + "maximum_draw": { + "type": "integer" + }, + "allocated_draw": { + "type": "integer" + } + }, + "required": [ + "name", + "type" + ] + } + }, + "power-outlets": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "iec-60320-c5", + "iec-60320-c7", + "iec-60320-c13", + "iec-60320-c15", + "iec-60320-c19", + "iec-60320-c21", + "iec-60309-p-n-e-4h", + "iec-60309-p-n-e-6h", + "iec-60309-p-n-e-9h", + "iec-60309-2p-e-4h", + "iec-60309-2p-e-6h", + "iec-60309-2p-e-9h", + "iec-60309-3p-e-4h", + "iec-60309-3p-e-6h", + "iec-60309-3p-e-9h", + "iec-60309-3p-n-e-4h", + "iec-60309-3p-n-e-6h", + "iec-60309-3p-n-e-9h", + "iec-60906-1", + "nbr-14136-10a", + "nbr-14136-20a", + "nema-1-15r", + "nema-5-15r", + "nema-5-20r", + "nema-5-30r", + "nema-5-50r", + "nema-6-15r", + "nema-6-20r", + "nema-6-30r", + "nema-6-50r", + "nema-10-30r", + "nema-10-50r", + "nema-14-20r", + "nema-14-30r", + "nema-14-50r", + "nema-14-60r", + "nema-15-15r", + "nema-15-20r", + "nema-15-30r", + "nema-15-50r", + "nema-15-60r", + "nema-l1-15r", + "nema-l5-15r", + "nema-l5-20r", + "nema-l5-30r", + "nema-l5-50r", + "nema-l6-15r", + "nema-l6-20r", + "nema-l6-30r", + "nema-l6-50r", + "nema-l10-30r", + "nema-l14-20r", + "nema-l14-30r", + "nema-l14-50r", + "nema-l14-60r", + "nema-l15-20r", + "nema-l15-30r", + "nema-l15-50r", + "nema-l15-60r", + "nema-l21-20r", + "nema-l21-30r", + "nema-l22-30r", + "CS6360C", + "CS6364C", + "CS8164C", + "CS8264C", + "CS8364C", + "CS8464C", + "ita-e", + "ita-f", + "ita-g", + "ita-h", + "ita-i", + "ita-j", + "ita-k", + "ita-l", + "ita-m", + "ita-n", + "ita-o", + "ita-multistandard", + "usb-a", + "usb-micro-b", + "usb-c", + "dc-terminal", + "hdot-cx", + "saf-d-grid", + "neutrik-powercon-20a", + "neutrik-powercon-32a", + "neutrik-powercon-true1", + "neutrik-powercon-true1-top", + "ubiquiti-smartpower", + "hardwired", + "other" + ] + }, + "power_port": { + "type": "string" + }, + "feed_leg": { + "type": "string", + "enum": [ + "A", + "B", + "C" + ] + } + }, + "required": [ + "name", + "type" + ] + } + }, + "interfaces": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "virtual", + "bridge", + "lag", + "100base-fx", + "100base-lfx", + "100base-tx", + "100base-t1", + "1000base-t", + "2.5gbase-t", + "5gbase-t", + "10gbase-t", + "10gbase-cx4", + "1000base-x-gbic", + "1000base-x-sfp", + "10gbase-x-sfpp", + "10gbase-x-xfp", + "10gbase-x-xenpak", + "10gbase-x-x2", + "25gbase-x-sfp28", + "50gbase-x-sfp56", + "40gbase-x-qsfpp", + "50gbase-x-sfp28", + "100gbase-x-cfp", + "100gbase-x-cfp2", + "200gbase-x-cfp2", + "400gbase-x-cfp2", + "100gbase-x-cfp4", + "100gbase-x-cxp", + "100gbase-x-cpak", + "100gbase-x-dsfp", + "100gbase-x-sfpdd", + "100gbase-x-qsfp28", + "100gbase-x-qsfpdd", + "200gbase-x-qsfp56", + "200gbase-x-qsfpdd", + "400gbase-x-qsfp112", + "400gbase-x-qsfpdd", + "400gbase-x-osfp", + "400gbase-x-osfp-rhs", + "400gbase-x-cdfp", + "400gbase-x-cfp8", + "800gbase-x-qsfpdd", + "800gbase-x-osfp", + "1000base-kx", + "10gbase-kr", + "10gbase-kx4", + "25gbase-kr", + "40gbase-kr4", + "50gbase-kr", + "100gbase-kp4", + "100gbase-kr2", + "100gbase-kr4", + "ieee802.11a", + "ieee802.11g", + "ieee802.11n", + "ieee802.11ac", + "ieee802.11ad", + "ieee802.11ax", + "ieee802.11ay", + "ieee802.15.1", + "other-wireless", + "gsm", + "cdma", + "lte", + "sonet-oc3", + "sonet-oc12", + "sonet-oc48", + "sonet-oc192", + "sonet-oc768", + "sonet-oc1920", + "sonet-oc3840", + "1gfc-sfp", + "2gfc-sfp", + "4gfc-sfp", + "8gfc-sfpp", + "16gfc-sfpp", + "32gfc-sfp28", + "64gfc-qsfpp", + "128gfc-qsfp28", + "infiniband-sdr", + "infiniband-ddr", + "infiniband-qdr", + "infiniband-fdr10", + "infiniband-fdr", + "infiniband-edr", + "infiniband-hdr", + "infiniband-ndr", + "infiniband-xdr", + "t1", + "e1", + "t3", + "e3", + "xdsl", + "docsis", + "gpon", + "xg-pon", + "xgs-pon", + "ng-pon2", + "epon", + "10g-epon", + "cisco-stackwise", + "cisco-stackwise-plus", + "cisco-flexstack", + "cisco-flexstack-plus", + "cisco-stackwise-80", + "cisco-stackwise-160", + "cisco-stackwise-320", + "cisco-stackwise-480", + "cisco-stackwise-1t", + "juniper-vcp", + "extreme-summitstack", + "extreme-summitstack-128", + "extreme-summitstack-256", + "extreme-summitstack-512", + "other" + ] + }, + "poe_mode": { + "type": "string", + "enum": [ + "pd", + "pse" + ] + }, + "poe_type": { + "type": "string", + "enum": [ + "type1-ieee802.3af", + "type2-ieee802.3at", + "type3-ieee802.3bt", + "type4-ieee802.3bt", + "passive-24v-2pair", + "passive-24v-4pair", + "passive-48v-2pair", + "passive-48v-4pair" + ] + }, + "mgmt_only": { + "type": "boolean" + } + }, + "required": [ + "name", + "type" + ] + } + }, + "front-ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "8p8c", + "8p6c", + "8p4c", + "8p2c", + "6p6c", + "6p4c", + "6p2c", + "4p4c", + "4p2c", + "gg45", + "tera-4p", + "tera-2p", + "tera-1p", + "110-punch", + "bnc", + "f", + "n", + "mrj21", + "fc", + "lc", + "lc-pc", + "lc-upc", + "lc-apc", + "lsh", + "lsh-pc", + "lsh-upc", + "lsh-apc", + "lx5", + "lx5-pc", + "lx5-upc", + "lx5-apc", + "mpo", + "mtrj", + "sc", + "sc-pc", + "sc-upc", + "sc-apc", + "st", + "cs", + "sn", + "sma-905", + "sma-906", + "urm-p2", + "urm-p4", + "urm-p8", + "splice", + "other" + ] + }, + "color": { + "type": "string", + "pattern": "^[a-f0-9]{6}$" + }, + "rear_port": { + "type": "string" + }, + "rear_port_position": { + "type": "integer" + } + }, + "required": [ + "name", + "type", + "rear_port" + ] + } + }, + "rear-ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "8p8c", + "8p6c", + "8p4c", + "8p2c", + "6p6c", + "6p4c", + "6p2c", + "4p4c", + "4p2c", + "gg45", + "tera-4p", + "tera-2p", + "tera-1p", + "110-punch", + "bnc", + "f", + "n", + "mrj21", + "fc", + "lc", + "lc-pc", + "lc-upc", + "lc-apc", + "lsh", + "lsh-pc", + "lsh-upc", + "lsh-apc", + "lx5", + "lx5-pc", + "lx5-upc", + "lx5-apc", + "mpo", + "mtrj", + "sc", + "sc-pc", + "sc-upc", + "sc-apc", + "st", + "cs", + "sn", + "sma-905", + "sma-906", + "urm-p2", + "urm-p4", + "urm-p8", + "splice", + "other" + ] + }, + "color": { + "type": "string", + "pattern": "^[a-f0-9]{6}$" + }, + "positions": { + "type": "integer" + }, + "poe": { + "type": "boolean" + } + }, + "required": [ + "name", + "type" + ] + } + }, + "module-bays": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "position": { + "type": "string" + } + }, + "required": [ + "name" + ] + } + }, + "device-bays": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + } + }, + "required": [ + "name" + ] + } + }, + "inventory-items": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "manufacturer": { + "type": "string" + }, + "part_id": { + "type": "string" + } + }, + "required": [ + "name" + ] + } + }, + "description": { + "type": "string" + }, + "comments": { + "type": "string" + } + }, + "required": ["manufacturer", "model", "slug"], + "additionalProperties": false +} diff --git a/pkg/netbox/schema/moduletype-for-go-jsonschema.json b/pkg/netbox/schema/moduletype-for-go-jsonschema.json new file mode 100644 index 00000000..232a6efd --- /dev/null +++ b/pkg/netbox/schema/moduletype-for-go-jsonschema.json @@ -0,0 +1,693 @@ +{ + "type": "object", + "properties": { + "manufacturer": { + "type": "string" + }, + "model": { + "type": "string" + }, + "part_number": { + "type": "string" + }, + "weight": { + "type": "number", + "minimum": 0, + "multipleOf": 0.01 + }, + "weight_unit": { + "type": "string", + "enum": [ + "kg", + "g", + "lb", + "oz" + ] + }, + "console-ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "de-9", + "db-25", + "rj-11", + "rj-12", + "rj-45", + "mini-din-8", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "other" + ] + }, + "poe": { + "type": "boolean" + } + }, + "required": [ + "name", + "type" + ] + } + }, + "console-server-ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "de-9", + "db-25", + "rj-11", + "rj-12", + "rj-45", + "mini-din-8", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "other" + ] + } + }, + "required": [ + "name", + "type" + ] + } + }, + "power-ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "iec-60320-c6", + "iec-60320-c8", + "iec-60320-c14", + "iec-60320-c16", + "iec-60320-c20", + "iec-60320-c22", + "iec-60309-p-n-e-4h", + "iec-60309-p-n-e-6h", + "iec-60309-p-n-e-9h", + "iec-60309-2p-e-4h", + "iec-60309-2p-e-6h", + "iec-60309-2p-e-9h", + "iec-60309-3p-e-4h", + "iec-60309-3p-e-6h", + "iec-60309-3p-e-9h", + "iec-60309-3p-n-e-4h", + "iec-60309-3p-n-e-6h", + "iec-60309-3p-n-e-9h", + "iec-60906-1", + "nbr-14136-10a", + "nbr-14136-20a", + "nema-1-15p", + "nema-5-15p", + "nema-5-20p", + "nema-5-30p", + "nema-5-50p", + "nema-6-15p", + "nema-6-20p", + "nema-6-30p", + "nema-6-50p", + "nema-10-30p", + "nema-10-50p", + "nema-14-20p", + "nema-14-30p", + "nema-14-50p", + "nema-14-60p", + "nema-15-15p", + "nema-15-20p", + "nema-15-30p", + "nema-15-50p", + "nema-15-60p", + "nema-l1-15p", + "nema-l5-15p", + "nema-l5-20p", + "nema-l5-30p", + "nema-l5-50p", + "nema-l6-15p", + "nema-l6-20p", + "nema-l6-30p", + "nema-l6-50p", + "nema-l10-30p", + "nema-l14-20p", + "nema-l14-30p", + "nema-l14-50p", + "nema-l14-60p", + "nema-l15-20p", + "nema-l15-30p", + "nema-l15-50p", + "nema-l15-60p", + "nema-l21-20p", + "nema-l21-30p", + "nema-l22-30p", + "cs6361c", + "cs6365c", + "cs8165c", + "cs8265c", + "cs8365c", + "cs8465c", + "ita-c", + "ita-e", + "ita-f", + "ita-ef", + "ita-g", + "ita-h", + "ita-i", + "ita-j", + "ita-k", + "ita-l", + "ita-m", + "ita-n", + "ita-o", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "usb-3-b", + "usb-3-micro-b", + "dc-terminal", + "saf-d-grid", + "neutrik-powercon-20", + "neutrik-powercon-32", + "neutrik-powercon-true1", + "neutrik-powercon-true1-top", + "ubiquiti-smartpower", + "hardwired", + "other" + ] + }, + "maximum_draw": { + "type": "integer" + }, + "allocated_draw": { + "type": "integer" + } + }, + "required": [ + "name", + "type" + ] + } + }, + "power-outlets": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "iec-60320-c5", + "iec-60320-c7", + "iec-60320-c13", + "iec-60320-c15", + "iec-60320-c19", + "iec-60320-c21", + "iec-60309-p-n-e-4h", + "iec-60309-p-n-e-6h", + "iec-60309-p-n-e-9h", + "iec-60309-2p-e-4h", + "iec-60309-2p-e-6h", + "iec-60309-2p-e-9h", + "iec-60309-3p-e-4h", + "iec-60309-3p-e-6h", + "iec-60309-3p-e-9h", + "iec-60309-3p-n-e-4h", + "iec-60309-3p-n-e-6h", + "iec-60309-3p-n-e-9h", + "iec-60906-1", + "nbr-14136-10a", + "nbr-14136-20a", + "nema-1-15r", + "nema-5-15r", + "nema-5-20r", + "nema-5-30r", + "nema-5-50r", + "nema-6-15r", + "nema-6-20r", + "nema-6-30r", + "nema-6-50r", + "nema-10-30r", + "nema-10-50r", + "nema-14-20r", + "nema-14-30r", + "nema-14-50r", + "nema-14-60r", + "nema-15-15r", + "nema-15-20r", + "nema-15-30r", + "nema-15-50r", + "nema-15-60r", + "nema-l1-15r", + "nema-l5-15r", + "nema-l5-20r", + "nema-l5-30r", + "nema-l5-50r", + "nema-l6-15r", + "nema-l6-20r", + "nema-l6-30r", + "nema-l6-50r", + "nema-l10-30r", + "nema-l14-20r", + "nema-l14-30r", + "nema-l14-50r", + "nema-l14-60r", + "nema-l15-20r", + "nema-l15-30r", + "nema-l15-50r", + "nema-l15-60r", + "nema-l21-20r", + "nema-l21-30r", + "nema-l22-30r", + "CS6360C", + "CS6364C", + "CS8164C", + "CS8264C", + "CS8364C", + "CS8464C", + "ita-e", + "ita-f", + "ita-g", + "ita-h", + "ita-i", + "ita-j", + "ita-k", + "ita-l", + "ita-m", + "ita-n", + "ita-o", + "ita-multistandard", + "usb-a", + "usb-micro-b", + "usb-c", + "dc-terminal", + "hdot-cx", + "saf-d-grid", + "neutrik-powercon-20a", + "neutrik-powercon-32a", + "neutrik-powercon-true1", + "neutrik-powercon-true1-top", + "ubiquiti-smartpower", + "hardwired", + "other" + ] + }, + "power_port": { + "type": "string" + }, + "feed_leg": { + "type": "string", + "enum": [ + "A", + "B", + "C" + ] + } + }, + "required": [ + "name", + "type" + ] + } + }, + "interfaces": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "virtual", + "bridge", + "lag", + "100base-fx", + "100base-lfx", + "100base-tx", + "100base-t1", + "1000base-t", + "2.5gbase-t", + "5gbase-t", + "10gbase-t", + "10gbase-cx4", + "1000base-x-gbic", + "1000base-x-sfp", + "10gbase-x-sfpp", + "10gbase-x-xfp", + "10gbase-x-xenpak", + "10gbase-x-x2", + "25gbase-x-sfp28", + "50gbase-x-sfp56", + "40gbase-x-qsfpp", + "50gbase-x-sfp28", + "100gbase-x-cfp", + "100gbase-x-cfp2", + "200gbase-x-cfp2", + "400gbase-x-cfp2", + "100gbase-x-cfp4", + "100gbase-x-cxp", + "100gbase-x-cpak", + "100gbase-x-dsfp", + "100gbase-x-sfpdd", + "100gbase-x-qsfp28", + "100gbase-x-qsfpdd", + "200gbase-x-qsfp56", + "200gbase-x-qsfpdd", + "400gbase-x-qsfp112", + "400gbase-x-qsfpdd", + "400gbase-x-osfp", + "400gbase-x-osfp-rhs", + "400gbase-x-cdfp", + "400gbase-x-cfp8", + "800gbase-x-qsfpdd", + "800gbase-x-osfp", + "1000base-kx", + "10gbase-kr", + "10gbase-kx4", + "25gbase-kr", + "40gbase-kr4", + "50gbase-kr", + "100gbase-kp4", + "100gbase-kr2", + "100gbase-kr4", + "ieee802.11a", + "ieee802.11g", + "ieee802.11n", + "ieee802.11ac", + "ieee802.11ad", + "ieee802.11ax", + "ieee802.11ay", + "ieee802.15.1", + "other-wireless", + "gsm", + "cdma", + "lte", + "sonet-oc3", + "sonet-oc12", + "sonet-oc48", + "sonet-oc192", + "sonet-oc768", + "sonet-oc1920", + "sonet-oc3840", + "1gfc-sfp", + "2gfc-sfp", + "4gfc-sfp", + "8gfc-sfpp", + "16gfc-sfpp", + "32gfc-sfp28", + "64gfc-qsfpp", + "128gfc-qsfp28", + "infiniband-sdr", + "infiniband-ddr", + "infiniband-qdr", + "infiniband-fdr10", + "infiniband-fdr", + "infiniband-edr", + "infiniband-hdr", + "infiniband-ndr", + "infiniband-xdr", + "t1", + "e1", + "t3", + "e3", + "xdsl", + "docsis", + "gpon", + "xg-pon", + "xgs-pon", + "ng-pon2", + "epon", + "10g-epon", + "cisco-stackwise", + "cisco-stackwise-plus", + "cisco-flexstack", + "cisco-flexstack-plus", + "cisco-stackwise-80", + "cisco-stackwise-160", + "cisco-stackwise-320", + "cisco-stackwise-480", + "cisco-stackwise-1t", + "juniper-vcp", + "extreme-summitstack", + "extreme-summitstack-128", + "extreme-summitstack-256", + "extreme-summitstack-512", + "other" + ] + }, + "poe_mode": { + "type": "string", + "enum": [ + "pd", + "pse" + ] + }, + "poe_type": { + "type": "string", + "enum": [ + "type1-ieee802.3af", + "type2-ieee802.3at", + "type3-ieee802.3bt", + "type4-ieee802.3bt", + "passive-24v-2pair", + "passive-24v-4pair", + "passive-48v-2pair", + "passive-48v-4pair" + ] + }, + "mgmt_only": { + "type": "boolean" + } + }, + "required": [ + "name", + "type" + ] + } + }, + "front-ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "8p8c", + "8p6c", + "8p4c", + "8p2c", + "6p6c", + "6p4c", + "6p2c", + "4p4c", + "4p2c", + "gg45", + "tera-4p", + "tera-2p", + "tera-1p", + "110-punch", + "bnc", + "f", + "n", + "mrj21", + "fc", + "lc", + "lc-pc", + "lc-upc", + "lc-apc", + "lsh", + "lsh-pc", + "lsh-upc", + "lsh-apc", + "lx5", + "lx5-pc", + "lx5-upc", + "lx5-apc", + "mpo", + "mtrj", + "sc", + "sc-pc", + "sc-upc", + "sc-apc", + "st", + "cs", + "sn", + "sma-905", + "sma-906", + "urm-p2", + "urm-p4", + "urm-p8", + "splice", + "other" + ] + }, + "color": { + "type": "string", + "pattern": "^[a-f0-9]{6}$" + }, + "rear_port": { + "type": "string" + }, + "rear_port_position": { + "type": "integer" + } + }, + "required": [ + "name", + "type", + "rear_port" + ] + } + }, + "rear-ports": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "label": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "8p8c", + "8p6c", + "8p4c", + "8p2c", + "6p6c", + "6p4c", + "6p2c", + "4p4c", + "4p2c", + "gg45", + "tera-4p", + "tera-2p", + "tera-1p", + "110-punch", + "bnc", + "f", + "n", + "mrj21", + "fc", + "lc", + "lc-pc", + "lc-upc", + "lc-apc", + "lsh", + "lsh-pc", + "lsh-upc", + "lsh-apc", + "lx5", + "lx5-pc", + "lx5-upc", + "lx5-apc", + "mpo", + "mtrj", + "sc", + "sc-pc", + "sc-upc", + "sc-apc", + "st", + "cs", + "sn", + "sma-905", + "sma-906", + "urm-p2", + "urm-p4", + "urm-p8", + "splice", + "other" + ] + }, + "color": { + "type": "string", + "pattern": "^[a-f0-9]{6}$" + }, + "positions": { + "type": "integer" + }, + "poe": { + "type": "boolean" + } + }, + "required": [ + "name", + "type" + ] + } + }, + "description": { + "type": "string" + }, + "comments": { + "type": "string" + } + }, + "required": ["manufacturer", "model"], + "additionalProperties": false +} diff --git a/pkg/netbox/types_devicetypes.go b/pkg/netbox/types_devicetypes.go new file mode 100644 index 00000000..e346fee3 --- /dev/null +++ b/pkg/netbox/types_devicetypes.go @@ -0,0 +1,1796 @@ +/* + * + * MIT License + * + * (C) Copyright 2024 Hewlett Packard Enterprise Development LP + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ +package netbox + +import ( + + "encoding/json" + "fmt" + + "os" + "reflect" + "gopkg.in/yaml.v3" +) + +// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. +type DeviceType struct { + // Airflow corresponds to the JSON schema field "airflow". + Airflow *DeviceTypeAirflow `json:"airflow,omitempty" yaml:"airflow,omitempty" mapstructure:"airflow,omitempty"` + + // Comments corresponds to the JSON schema field "comments". + Comments *string `json:"comments,omitempty" yaml:"comments,omitempty" mapstructure:"comments,omitempty"` + + // ConsolePorts corresponds to the JSON schema field "console-ports". + ConsolePorts []DeviceTypeConsolePortsElem `json:"console-ports,omitempty" yaml:"console-ports,omitempty" mapstructure:"console-ports,omitempty"` + + // ConsoleServerPorts corresponds to the JSON schema field "console-server-ports". + ConsoleServerPorts []DeviceTypeConsoleServerPortsElem `json:"console-server-ports,omitempty" yaml:"console-server-ports,omitempty" mapstructure:"console-server-ports,omitempty"` + + // Description corresponds to the JSON schema field "description". + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` + + // DeviceBays corresponds to the JSON schema field "device-bays". + DeviceBays []DeviceTypeDeviceBaysElem `json:"device-bays,omitempty" yaml:"device-bays,omitempty" mapstructure:"device-bays,omitempty"` + + // FrontPorts corresponds to the JSON schema field "front-ports". + FrontPorts []DeviceTypeFrontPortsElem `json:"front-ports,omitempty" yaml:"front-ports,omitempty" mapstructure:"front-ports,omitempty"` + + // FrontImage corresponds to the JSON schema field "front_image". + FrontImage *bool `json:"front_image,omitempty" yaml:"front_image,omitempty" mapstructure:"front_image,omitempty"` + + // Interfaces corresponds to the JSON schema field "interfaces". + Interfaces []DeviceTypeInterfacesElem `json:"interfaces,omitempty" yaml:"interfaces,omitempty" mapstructure:"interfaces,omitempty"` + + // InventoryItems corresponds to the JSON schema field "inventory-items". + InventoryItems []DeviceTypeInventoryItemsElem `json:"inventory-items,omitempty" yaml:"inventory-items,omitempty" mapstructure:"inventory-items,omitempty"` + + // IsFullDepth corresponds to the JSON schema field "is_full_depth". + IsFullDepth *bool `json:"is_full_depth,omitempty" yaml:"is_full_depth,omitempty" mapstructure:"is_full_depth,omitempty"` + + // IsPowered corresponds to the JSON schema field "is_powered". + IsPowered *bool `json:"is_powered,omitempty" yaml:"is_powered,omitempty" mapstructure:"is_powered,omitempty"` + + // Manufacturer corresponds to the JSON schema field "manufacturer". + Manufacturer string `json:"manufacturer" yaml:"manufacturer" mapstructure:"manufacturer"` + + // Model corresponds to the JSON schema field "model". + Model string `json:"model" yaml:"model" mapstructure:"model"` + + // ModuleBays corresponds to the JSON schema field "module-bays". + ModuleBays []DeviceTypeModuleBaysElem `json:"module-bays,omitempty" yaml:"module-bays,omitempty" mapstructure:"module-bays,omitempty"` + + // PartNumber corresponds to the JSON schema field "part_number". + PartNumber *string `json:"part_number,omitempty" yaml:"part_number,omitempty" mapstructure:"part_number,omitempty"` + + // PowerOutlets corresponds to the JSON schema field "power-outlets". + PowerOutlets []DeviceTypePowerOutletsElem `json:"power-outlets,omitempty" yaml:"power-outlets,omitempty" mapstructure:"power-outlets,omitempty"` + + // PowerPorts corresponds to the JSON schema field "power-ports". + PowerPorts []DeviceTypePowerPortsElem `json:"power-ports,omitempty" yaml:"power-ports,omitempty" mapstructure:"power-ports,omitempty"` + + // RearPorts corresponds to the JSON schema field "rear-ports". + RearPorts []DeviceTypeRearPortsElem `json:"rear-ports,omitempty" yaml:"rear-ports,omitempty" mapstructure:"rear-ports,omitempty"` + + // RearImage corresponds to the JSON schema field "rear_image". + RearImage *bool `json:"rear_image,omitempty" yaml:"rear_image,omitempty" mapstructure:"rear_image,omitempty"` + + // Slug corresponds to the JSON schema field "slug". + Slug string `json:"slug" yaml:"slug" mapstructure:"slug"` + + // SubdeviceRole corresponds to the JSON schema field "subdevice_role". + SubdeviceRole *DeviceTypeSubdeviceRole `json:"subdevice_role,omitempty" yaml:"subdevice_role,omitempty" mapstructure:"subdevice_role,omitempty"` + + // UHeight corresponds to the JSON schema field "u_height". + UHeight *float64 `json:"u_height,omitempty" yaml:"u_height,omitempty" mapstructure:"u_height,omitempty"` + + // Weight corresponds to the JSON schema field "weight". + Weight *float64 `json:"weight,omitempty" yaml:"weight,omitempty" mapstructure:"weight,omitempty"` + + // WeightUnit corresponds to the JSON schema field "weight_unit". + WeightUnit *DeviceTypeWeightUnit `json:"weight_unit,omitempty" yaml:"weight_unit,omitempty" mapstructure:"weight_unit,omitempty"` +} + +type DeviceTypeAirflow string + +const DeviceTypeAirflowFrontToRear DeviceTypeAirflow = "front-to-rear" +const DeviceTypeAirflowLeftToRight DeviceTypeAirflow = "left-to-right" +const DeviceTypeAirflowMixed DeviceTypeAirflow = "mixed" +const DeviceTypeAirflowPassive DeviceTypeAirflow = "passive" +const DeviceTypeAirflowRearToFront DeviceTypeAirflow = "rear-to-front" +const DeviceTypeAirflowRightToLeft DeviceTypeAirflow = "right-to-left" +const DeviceTypeAirflowSideToRear DeviceTypeAirflow = "side-to-rear" + +type DeviceTypeConsolePortsElem struct { + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // Poe corresponds to the JSON schema field "poe". + Poe *bool `json:"poe,omitempty" yaml:"poe,omitempty" mapstructure:"poe,omitempty"` + + // Type corresponds to the JSON schema field "type". + Type DeviceTypeConsolePortsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type DeviceTypeConsolePortsElemType string + +const DeviceTypeConsolePortsElemTypeDb25 DeviceTypeConsolePortsElemType = "db-25" +const DeviceTypeConsolePortsElemTypeDe9 DeviceTypeConsolePortsElemType = "de-9" +const DeviceTypeConsolePortsElemTypeMiniDin8 DeviceTypeConsolePortsElemType = "mini-din-8" +const DeviceTypeConsolePortsElemTypeOther DeviceTypeConsolePortsElemType = "other" +const DeviceTypeConsolePortsElemTypeRj11 DeviceTypeConsolePortsElemType = "rj-11" +const DeviceTypeConsolePortsElemTypeRj12 DeviceTypeConsolePortsElemType = "rj-12" +const DeviceTypeConsolePortsElemTypeRj45 DeviceTypeConsolePortsElemType = "rj-45" +const DeviceTypeConsolePortsElemTypeUsbA DeviceTypeConsolePortsElemType = "usb-a" +const DeviceTypeConsolePortsElemTypeUsbB DeviceTypeConsolePortsElemType = "usb-b" +const DeviceTypeConsolePortsElemTypeUsbC DeviceTypeConsolePortsElemType = "usb-c" +const DeviceTypeConsolePortsElemTypeUsbMicroA DeviceTypeConsolePortsElemType = "usb-micro-a" +const DeviceTypeConsolePortsElemTypeUsbMicroAb DeviceTypeConsolePortsElemType = "usb-micro-ab" +const DeviceTypeConsolePortsElemTypeUsbMicroB DeviceTypeConsolePortsElemType = "usb-micro-b" +const DeviceTypeConsolePortsElemTypeUsbMiniA DeviceTypeConsolePortsElemType = "usb-mini-a" +const DeviceTypeConsolePortsElemTypeUsbMiniB DeviceTypeConsolePortsElemType = "usb-mini-b" + +type DeviceTypeConsoleServerPortsElem struct { + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // Type corresponds to the JSON schema field "type". + Type DeviceTypeConsoleServerPortsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type DeviceTypeConsoleServerPortsElemType string + +const DeviceTypeConsoleServerPortsElemTypeDb25 DeviceTypeConsoleServerPortsElemType = "db-25" +const DeviceTypeConsoleServerPortsElemTypeDe9 DeviceTypeConsoleServerPortsElemType = "de-9" +const DeviceTypeConsoleServerPortsElemTypeMiniDin8 DeviceTypeConsoleServerPortsElemType = "mini-din-8" +const DeviceTypeConsoleServerPortsElemTypeOther DeviceTypeConsoleServerPortsElemType = "other" +const DeviceTypeConsoleServerPortsElemTypeRj11 DeviceTypeConsoleServerPortsElemType = "rj-11" +const DeviceTypeConsoleServerPortsElemTypeRj12 DeviceTypeConsoleServerPortsElemType = "rj-12" +const DeviceTypeConsoleServerPortsElemTypeRj45 DeviceTypeConsoleServerPortsElemType = "rj-45" +const DeviceTypeConsoleServerPortsElemTypeUsbA DeviceTypeConsoleServerPortsElemType = "usb-a" +const DeviceTypeConsoleServerPortsElemTypeUsbB DeviceTypeConsoleServerPortsElemType = "usb-b" +const DeviceTypeConsoleServerPortsElemTypeUsbC DeviceTypeConsoleServerPortsElemType = "usb-c" +const DeviceTypeConsoleServerPortsElemTypeUsbMicroA DeviceTypeConsoleServerPortsElemType = "usb-micro-a" +const DeviceTypeConsoleServerPortsElemTypeUsbMicroAb DeviceTypeConsoleServerPortsElemType = "usb-micro-ab" +const DeviceTypeConsoleServerPortsElemTypeUsbMicroB DeviceTypeConsoleServerPortsElemType = "usb-micro-b" +const DeviceTypeConsoleServerPortsElemTypeUsbMiniA DeviceTypeConsoleServerPortsElemType = "usb-mini-a" +const DeviceTypeConsoleServerPortsElemTypeUsbMiniB DeviceTypeConsoleServerPortsElemType = "usb-mini-b" + +type DeviceTypeDeviceBaysElem struct { + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` +} + +type DeviceTypeFrontPortsElem struct { + // Color corresponds to the JSON schema field "color". + Color *string `json:"color,omitempty" yaml:"color,omitempty" mapstructure:"color,omitempty"` + + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // RearPort corresponds to the JSON schema field "rear_port". + RearPort string `json:"rear_port" yaml:"rear_port" mapstructure:"rear_port"` + + // RearPortPosition corresponds to the JSON schema field "rear_port_position". + RearPortPosition *int `json:"rear_port_position,omitempty" yaml:"rear_port_position,omitempty" mapstructure:"rear_port_position,omitempty"` + + // Type corresponds to the JSON schema field "type". + Type DeviceTypeFrontPortsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type DeviceTypeFrontPortsElemType string + +const DeviceTypeFrontPortsElemTypeA110Punch DeviceTypeFrontPortsElemType = "110-punch" +const DeviceTypeFrontPortsElemTypeA4P2C DeviceTypeFrontPortsElemType = "4p2c" +const DeviceTypeFrontPortsElemTypeA4P4C DeviceTypeFrontPortsElemType = "4p4c" +const DeviceTypeFrontPortsElemTypeA6P2C DeviceTypeFrontPortsElemType = "6p2c" +const DeviceTypeFrontPortsElemTypeA6P4C DeviceTypeFrontPortsElemType = "6p4c" +const DeviceTypeFrontPortsElemTypeA6P6C DeviceTypeFrontPortsElemType = "6p6c" +const DeviceTypeFrontPortsElemTypeA8P2C DeviceTypeFrontPortsElemType = "8p2c" +const DeviceTypeFrontPortsElemTypeA8P4C DeviceTypeFrontPortsElemType = "8p4c" +const DeviceTypeFrontPortsElemTypeA8P6C DeviceTypeFrontPortsElemType = "8p6c" +const DeviceTypeFrontPortsElemTypeA8P8C DeviceTypeFrontPortsElemType = "8p8c" +const DeviceTypeFrontPortsElemTypeBnc DeviceTypeFrontPortsElemType = "bnc" +const DeviceTypeFrontPortsElemTypeCs DeviceTypeFrontPortsElemType = "cs" +const DeviceTypeFrontPortsElemTypeF DeviceTypeFrontPortsElemType = "f" +const DeviceTypeFrontPortsElemTypeFc DeviceTypeFrontPortsElemType = "fc" +const DeviceTypeFrontPortsElemTypeGg45 DeviceTypeFrontPortsElemType = "gg45" +const DeviceTypeFrontPortsElemTypeLc DeviceTypeFrontPortsElemType = "lc" +const DeviceTypeFrontPortsElemTypeLcApc DeviceTypeFrontPortsElemType = "lc-apc" +const DeviceTypeFrontPortsElemTypeLcPc DeviceTypeFrontPortsElemType = "lc-pc" +const DeviceTypeFrontPortsElemTypeLcUpc DeviceTypeFrontPortsElemType = "lc-upc" +const DeviceTypeFrontPortsElemTypeLsh DeviceTypeFrontPortsElemType = "lsh" +const DeviceTypeFrontPortsElemTypeLshApc DeviceTypeFrontPortsElemType = "lsh-apc" +const DeviceTypeFrontPortsElemTypeLshPc DeviceTypeFrontPortsElemType = "lsh-pc" +const DeviceTypeFrontPortsElemTypeLshUpc DeviceTypeFrontPortsElemType = "lsh-upc" +const DeviceTypeFrontPortsElemTypeLx5 DeviceTypeFrontPortsElemType = "lx5" +const DeviceTypeFrontPortsElemTypeLx5Apc DeviceTypeFrontPortsElemType = "lx5-apc" +const DeviceTypeFrontPortsElemTypeLx5Pc DeviceTypeFrontPortsElemType = "lx5-pc" +const DeviceTypeFrontPortsElemTypeLx5Upc DeviceTypeFrontPortsElemType = "lx5-upc" +const DeviceTypeFrontPortsElemTypeMpo DeviceTypeFrontPortsElemType = "mpo" +const DeviceTypeFrontPortsElemTypeMrj21 DeviceTypeFrontPortsElemType = "mrj21" +const DeviceTypeFrontPortsElemTypeMtrj DeviceTypeFrontPortsElemType = "mtrj" +const DeviceTypeFrontPortsElemTypeN DeviceTypeFrontPortsElemType = "n" +const DeviceTypeFrontPortsElemTypeOther DeviceTypeFrontPortsElemType = "other" +const DeviceTypeFrontPortsElemTypeSc DeviceTypeFrontPortsElemType = "sc" +const DeviceTypeFrontPortsElemTypeScApc DeviceTypeFrontPortsElemType = "sc-apc" +const DeviceTypeFrontPortsElemTypeScPc DeviceTypeFrontPortsElemType = "sc-pc" +const DeviceTypeFrontPortsElemTypeScUpc DeviceTypeFrontPortsElemType = "sc-upc" +const DeviceTypeFrontPortsElemTypeSma905 DeviceTypeFrontPortsElemType = "sma-905" +const DeviceTypeFrontPortsElemTypeSma906 DeviceTypeFrontPortsElemType = "sma-906" +const DeviceTypeFrontPortsElemTypeSn DeviceTypeFrontPortsElemType = "sn" +const DeviceTypeFrontPortsElemTypeSplice DeviceTypeFrontPortsElemType = "splice" +const DeviceTypeFrontPortsElemTypeSt DeviceTypeFrontPortsElemType = "st" +const DeviceTypeFrontPortsElemTypeTera1P DeviceTypeFrontPortsElemType = "tera-1p" +const DeviceTypeFrontPortsElemTypeTera2P DeviceTypeFrontPortsElemType = "tera-2p" +const DeviceTypeFrontPortsElemTypeTera4P DeviceTypeFrontPortsElemType = "tera-4p" +const DeviceTypeFrontPortsElemTypeUrmP2 DeviceTypeFrontPortsElemType = "urm-p2" +const DeviceTypeFrontPortsElemTypeUrmP4 DeviceTypeFrontPortsElemType = "urm-p4" +const DeviceTypeFrontPortsElemTypeUrmP8 DeviceTypeFrontPortsElemType = "urm-p8" + +type DeviceTypeInterfacesElem struct { + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // MgmtOnly corresponds to the JSON schema field "mgmt_only". + MgmtOnly *bool `json:"mgmt_only,omitempty" yaml:"mgmt_only,omitempty" mapstructure:"mgmt_only,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // PoeMode corresponds to the JSON schema field "poe_mode". + PoeMode *DeviceTypeInterfacesElemPoeMode `json:"poe_mode,omitempty" yaml:"poe_mode,omitempty" mapstructure:"poe_mode,omitempty"` + + // PoeType corresponds to the JSON schema field "poe_type". + PoeType *DeviceTypeInterfacesElemPoeType `json:"poe_type,omitempty" yaml:"poe_type,omitempty" mapstructure:"poe_type,omitempty"` + + // Type corresponds to the JSON schema field "type". + Type DeviceTypeInterfacesElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type DeviceTypeInterfacesElemPoeMode string + +const DeviceTypeInterfacesElemPoeModePd DeviceTypeInterfacesElemPoeMode = "pd" +const DeviceTypeInterfacesElemPoeModePse DeviceTypeInterfacesElemPoeMode = "pse" + +type DeviceTypeInterfacesElemPoeType string + +const DeviceTypeInterfacesElemPoeTypePassive24V2Pair DeviceTypeInterfacesElemPoeType = "passive-24v-2pair" +const DeviceTypeInterfacesElemPoeTypePassive24V4Pair DeviceTypeInterfacesElemPoeType = "passive-24v-4pair" +const DeviceTypeInterfacesElemPoeTypePassive48V2Pair DeviceTypeInterfacesElemPoeType = "passive-48v-2pair" +const DeviceTypeInterfacesElemPoeTypePassive48V4Pair DeviceTypeInterfacesElemPoeType = "passive-48v-4pair" +const DeviceTypeInterfacesElemPoeTypeType1Ieee8023Af DeviceTypeInterfacesElemPoeType = "type1-ieee802.3af" +const DeviceTypeInterfacesElemPoeTypeType2Ieee8023At DeviceTypeInterfacesElemPoeType = "type2-ieee802.3at" +const DeviceTypeInterfacesElemPoeTypeType3Ieee8023Bt DeviceTypeInterfacesElemPoeType = "type3-ieee802.3bt" +const DeviceTypeInterfacesElemPoeTypeType4Ieee8023Bt DeviceTypeInterfacesElemPoeType = "type4-ieee802.3bt" + +type DeviceTypeInterfacesElemType string + +const DeviceTypeInterfacesElemTypeA1000BaseKx DeviceTypeInterfacesElemType = "1000base-kx" +const DeviceTypeInterfacesElemTypeA1000BaseT DeviceTypeInterfacesElemType = "1000base-t" +const DeviceTypeInterfacesElemTypeA1000BaseXGbic DeviceTypeInterfacesElemType = "1000base-x-gbic" +const DeviceTypeInterfacesElemTypeA1000BaseXSfp DeviceTypeInterfacesElemType = "1000base-x-sfp" +const DeviceTypeInterfacesElemTypeA100BaseFx DeviceTypeInterfacesElemType = "100base-fx" +const DeviceTypeInterfacesElemTypeA100BaseLfx DeviceTypeInterfacesElemType = "100base-lfx" +const DeviceTypeInterfacesElemTypeA100BaseT1 DeviceTypeInterfacesElemType = "100base-t1" +const DeviceTypeInterfacesElemTypeA100BaseTx DeviceTypeInterfacesElemType = "100base-tx" +const DeviceTypeInterfacesElemTypeA100GbaseKp4 DeviceTypeInterfacesElemType = "100gbase-kp4" +const DeviceTypeInterfacesElemTypeA100GbaseKr2 DeviceTypeInterfacesElemType = "100gbase-kr2" +const DeviceTypeInterfacesElemTypeA100GbaseKr4 DeviceTypeInterfacesElemType = "100gbase-kr4" +const DeviceTypeInterfacesElemTypeA100GbaseXCfp DeviceTypeInterfacesElemType = "100gbase-x-cfp" +const DeviceTypeInterfacesElemTypeA100GbaseXCfp2 DeviceTypeInterfacesElemType = "100gbase-x-cfp2" +const DeviceTypeInterfacesElemTypeA100GbaseXCfp4 DeviceTypeInterfacesElemType = "100gbase-x-cfp4" +const DeviceTypeInterfacesElemTypeA100GbaseXCpak DeviceTypeInterfacesElemType = "100gbase-x-cpak" +const DeviceTypeInterfacesElemTypeA100GbaseXCxp DeviceTypeInterfacesElemType = "100gbase-x-cxp" +const DeviceTypeInterfacesElemTypeA100GbaseXDsfp DeviceTypeInterfacesElemType = "100gbase-x-dsfp" +const DeviceTypeInterfacesElemTypeA100GbaseXQsfp28 DeviceTypeInterfacesElemType = "100gbase-x-qsfp28" +const DeviceTypeInterfacesElemTypeA100GbaseXQsfpdd DeviceTypeInterfacesElemType = "100gbase-x-qsfpdd" +const DeviceTypeInterfacesElemTypeA100GbaseXSfpdd DeviceTypeInterfacesElemType = "100gbase-x-sfpdd" +const DeviceTypeInterfacesElemTypeA10GEpon DeviceTypeInterfacesElemType = "10g-epon" +const DeviceTypeInterfacesElemTypeA10GbaseCx4 DeviceTypeInterfacesElemType = "10gbase-cx4" +const DeviceTypeInterfacesElemTypeA10GbaseKr DeviceTypeInterfacesElemType = "10gbase-kr" +const DeviceTypeInterfacesElemTypeA10GbaseKx4 DeviceTypeInterfacesElemType = "10gbase-kx4" +const DeviceTypeInterfacesElemTypeA10GbaseT DeviceTypeInterfacesElemType = "10gbase-t" +const DeviceTypeInterfacesElemTypeA10GbaseXSfpp DeviceTypeInterfacesElemType = "10gbase-x-sfpp" +const DeviceTypeInterfacesElemTypeA10GbaseXX2 DeviceTypeInterfacesElemType = "10gbase-x-x2" +const DeviceTypeInterfacesElemTypeA10GbaseXXenpak DeviceTypeInterfacesElemType = "10gbase-x-xenpak" +const DeviceTypeInterfacesElemTypeA10GbaseXXfp DeviceTypeInterfacesElemType = "10gbase-x-xfp" +const DeviceTypeInterfacesElemTypeA128GfcQsfp28 DeviceTypeInterfacesElemType = "128gfc-qsfp28" +const DeviceTypeInterfacesElemTypeA16GfcSfpp DeviceTypeInterfacesElemType = "16gfc-sfpp" +const DeviceTypeInterfacesElemTypeA1GfcSfp DeviceTypeInterfacesElemType = "1gfc-sfp" +const DeviceTypeInterfacesElemTypeA200GbaseXCfp2 DeviceTypeInterfacesElemType = "200gbase-x-cfp2" +const DeviceTypeInterfacesElemTypeA200GbaseXQsfp56 DeviceTypeInterfacesElemType = "200gbase-x-qsfp56" +const DeviceTypeInterfacesElemTypeA200GbaseXQsfpdd DeviceTypeInterfacesElemType = "200gbase-x-qsfpdd" +const DeviceTypeInterfacesElemTypeA25GbaseKr DeviceTypeInterfacesElemType = "25gbase-kr" +const DeviceTypeInterfacesElemTypeA25GbaseT DeviceTypeInterfacesElemType = "2.5gbase-t" +const DeviceTypeInterfacesElemTypeA25GbaseXSfp28 DeviceTypeInterfacesElemType = "25gbase-x-sfp28" +const DeviceTypeInterfacesElemTypeA2GfcSfp DeviceTypeInterfacesElemType = "2gfc-sfp" +const DeviceTypeInterfacesElemTypeA32GfcSfp28 DeviceTypeInterfacesElemType = "32gfc-sfp28" +const DeviceTypeInterfacesElemTypeA400GbaseXCdfp DeviceTypeInterfacesElemType = "400gbase-x-cdfp" +const DeviceTypeInterfacesElemTypeA400GbaseXCfp2 DeviceTypeInterfacesElemType = "400gbase-x-cfp2" +const DeviceTypeInterfacesElemTypeA400GbaseXCfp8 DeviceTypeInterfacesElemType = "400gbase-x-cfp8" +const DeviceTypeInterfacesElemTypeA400GbaseXOsfp DeviceTypeInterfacesElemType = "400gbase-x-osfp" +const DeviceTypeInterfacesElemTypeA400GbaseXOsfpRhs DeviceTypeInterfacesElemType = "400gbase-x-osfp-rhs" +const DeviceTypeInterfacesElemTypeA400GbaseXQsfp112 DeviceTypeInterfacesElemType = "400gbase-x-qsfp112" +const DeviceTypeInterfacesElemTypeA400GbaseXQsfpdd DeviceTypeInterfacesElemType = "400gbase-x-qsfpdd" +const DeviceTypeInterfacesElemTypeA40GbaseKr4 DeviceTypeInterfacesElemType = "40gbase-kr4" +const DeviceTypeInterfacesElemTypeA40GbaseXQsfpp DeviceTypeInterfacesElemType = "40gbase-x-qsfpp" +const DeviceTypeInterfacesElemTypeA4GfcSfp DeviceTypeInterfacesElemType = "4gfc-sfp" +const DeviceTypeInterfacesElemTypeA50GbaseKr DeviceTypeInterfacesElemType = "50gbase-kr" +const DeviceTypeInterfacesElemTypeA50GbaseXSfp28 DeviceTypeInterfacesElemType = "50gbase-x-sfp28" +const DeviceTypeInterfacesElemTypeA50GbaseXSfp56 DeviceTypeInterfacesElemType = "50gbase-x-sfp56" +const DeviceTypeInterfacesElemTypeA5GbaseT DeviceTypeInterfacesElemType = "5gbase-t" +const DeviceTypeInterfacesElemTypeA64GfcQsfpp DeviceTypeInterfacesElemType = "64gfc-qsfpp" +const DeviceTypeInterfacesElemTypeA800GbaseXOsfp DeviceTypeInterfacesElemType = "800gbase-x-osfp" +const DeviceTypeInterfacesElemTypeA800GbaseXQsfpdd DeviceTypeInterfacesElemType = "800gbase-x-qsfpdd" +const DeviceTypeInterfacesElemTypeA8GfcSfpp DeviceTypeInterfacesElemType = "8gfc-sfpp" +const DeviceTypeInterfacesElemTypeBridge DeviceTypeInterfacesElemType = "bridge" +const DeviceTypeInterfacesElemTypeCdma DeviceTypeInterfacesElemType = "cdma" +const DeviceTypeInterfacesElemTypeCiscoFlexstack DeviceTypeInterfacesElemType = "cisco-flexstack" +const DeviceTypeInterfacesElemTypeCiscoFlexstackPlus DeviceTypeInterfacesElemType = "cisco-flexstack-plus" +const DeviceTypeInterfacesElemTypeCiscoStackwise DeviceTypeInterfacesElemType = "cisco-stackwise" +const DeviceTypeInterfacesElemTypeCiscoStackwise160 DeviceTypeInterfacesElemType = "cisco-stackwise-160" +const DeviceTypeInterfacesElemTypeCiscoStackwise1T DeviceTypeInterfacesElemType = "cisco-stackwise-1t" +const DeviceTypeInterfacesElemTypeCiscoStackwise320 DeviceTypeInterfacesElemType = "cisco-stackwise-320" +const DeviceTypeInterfacesElemTypeCiscoStackwise480 DeviceTypeInterfacesElemType = "cisco-stackwise-480" +const DeviceTypeInterfacesElemTypeCiscoStackwise80 DeviceTypeInterfacesElemType = "cisco-stackwise-80" +const DeviceTypeInterfacesElemTypeCiscoStackwisePlus DeviceTypeInterfacesElemType = "cisco-stackwise-plus" +const DeviceTypeInterfacesElemTypeDocsis DeviceTypeInterfacesElemType = "docsis" +const DeviceTypeInterfacesElemTypeE1 DeviceTypeInterfacesElemType = "e1" +const DeviceTypeInterfacesElemTypeE3 DeviceTypeInterfacesElemType = "e3" +const DeviceTypeInterfacesElemTypeEpon DeviceTypeInterfacesElemType = "epon" +const DeviceTypeInterfacesElemTypeExtremeSummitstack DeviceTypeInterfacesElemType = "extreme-summitstack" +const DeviceTypeInterfacesElemTypeExtremeSummitstack128 DeviceTypeInterfacesElemType = "extreme-summitstack-128" +const DeviceTypeInterfacesElemTypeExtremeSummitstack256 DeviceTypeInterfacesElemType = "extreme-summitstack-256" +const DeviceTypeInterfacesElemTypeExtremeSummitstack512 DeviceTypeInterfacesElemType = "extreme-summitstack-512" +const DeviceTypeInterfacesElemTypeGpon DeviceTypeInterfacesElemType = "gpon" +const DeviceTypeInterfacesElemTypeGsm DeviceTypeInterfacesElemType = "gsm" +const DeviceTypeInterfacesElemTypeIeee80211A DeviceTypeInterfacesElemType = "ieee802.11a" +const DeviceTypeInterfacesElemTypeIeee80211Ac DeviceTypeInterfacesElemType = "ieee802.11ac" +const DeviceTypeInterfacesElemTypeIeee80211Ad DeviceTypeInterfacesElemType = "ieee802.11ad" +const DeviceTypeInterfacesElemTypeIeee80211Ax DeviceTypeInterfacesElemType = "ieee802.11ax" +const DeviceTypeInterfacesElemTypeIeee80211Ay DeviceTypeInterfacesElemType = "ieee802.11ay" +const DeviceTypeInterfacesElemTypeIeee80211G DeviceTypeInterfacesElemType = "ieee802.11g" +const DeviceTypeInterfacesElemTypeIeee80211N DeviceTypeInterfacesElemType = "ieee802.11n" +const DeviceTypeInterfacesElemTypeIeee802151 DeviceTypeInterfacesElemType = "ieee802.15.1" +const DeviceTypeInterfacesElemTypeInfinibandDdr DeviceTypeInterfacesElemType = "infiniband-ddr" +const DeviceTypeInterfacesElemTypeInfinibandEdr DeviceTypeInterfacesElemType = "infiniband-edr" +const DeviceTypeInterfacesElemTypeInfinibandFdr DeviceTypeInterfacesElemType = "infiniband-fdr" +const DeviceTypeInterfacesElemTypeInfinibandFdr10 DeviceTypeInterfacesElemType = "infiniband-fdr10" +const DeviceTypeInterfacesElemTypeInfinibandHdr DeviceTypeInterfacesElemType = "infiniband-hdr" +const DeviceTypeInterfacesElemTypeInfinibandNdr DeviceTypeInterfacesElemType = "infiniband-ndr" +const DeviceTypeInterfacesElemTypeInfinibandQdr DeviceTypeInterfacesElemType = "infiniband-qdr" +const DeviceTypeInterfacesElemTypeInfinibandSdr DeviceTypeInterfacesElemType = "infiniband-sdr" +const DeviceTypeInterfacesElemTypeInfinibandXdr DeviceTypeInterfacesElemType = "infiniband-xdr" +const DeviceTypeInterfacesElemTypeJuniperVcp DeviceTypeInterfacesElemType = "juniper-vcp" +const DeviceTypeInterfacesElemTypeLag DeviceTypeInterfacesElemType = "lag" +const DeviceTypeInterfacesElemTypeLte DeviceTypeInterfacesElemType = "lte" +const DeviceTypeInterfacesElemTypeNgPon2 DeviceTypeInterfacesElemType = "ng-pon2" +const DeviceTypeInterfacesElemTypeOther DeviceTypeInterfacesElemType = "other" +const DeviceTypeInterfacesElemTypeOtherWireless DeviceTypeInterfacesElemType = "other-wireless" +const DeviceTypeInterfacesElemTypeSonetOc12 DeviceTypeInterfacesElemType = "sonet-oc12" +const DeviceTypeInterfacesElemTypeSonetOc192 DeviceTypeInterfacesElemType = "sonet-oc192" +const DeviceTypeInterfacesElemTypeSonetOc1920 DeviceTypeInterfacesElemType = "sonet-oc1920" +const DeviceTypeInterfacesElemTypeSonetOc3 DeviceTypeInterfacesElemType = "sonet-oc3" +const DeviceTypeInterfacesElemTypeSonetOc3840 DeviceTypeInterfacesElemType = "sonet-oc3840" +const DeviceTypeInterfacesElemTypeSonetOc48 DeviceTypeInterfacesElemType = "sonet-oc48" +const DeviceTypeInterfacesElemTypeSonetOc768 DeviceTypeInterfacesElemType = "sonet-oc768" +const DeviceTypeInterfacesElemTypeT1 DeviceTypeInterfacesElemType = "t1" +const DeviceTypeInterfacesElemTypeT3 DeviceTypeInterfacesElemType = "t3" +const DeviceTypeInterfacesElemTypeVirtual DeviceTypeInterfacesElemType = "virtual" +const DeviceTypeInterfacesElemTypeXdsl DeviceTypeInterfacesElemType = "xdsl" +const DeviceTypeInterfacesElemTypeXgPon DeviceTypeInterfacesElemType = "xg-pon" +const DeviceTypeInterfacesElemTypeXgsPon DeviceTypeInterfacesElemType = "xgs-pon" + +type DeviceTypeInventoryItemsElem struct { + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Manufacturer corresponds to the JSON schema field "manufacturer". + Manufacturer *string `json:"manufacturer,omitempty" yaml:"manufacturer,omitempty" mapstructure:"manufacturer,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // PartId corresponds to the JSON schema field "part_id". + PartId *string `json:"part_id,omitempty" yaml:"part_id,omitempty" mapstructure:"part_id,omitempty"` +} + +type DeviceTypeModuleBaysElem struct { + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // Position corresponds to the JSON schema field "position". + Position *string `json:"position,omitempty" yaml:"position,omitempty" mapstructure:"position,omitempty"` +} + +type DeviceTypePowerOutletsElem struct { + // FeedLeg corresponds to the JSON schema field "feed_leg". + FeedLeg *DeviceTypePowerOutletsElemFeedLeg `json:"feed_leg,omitempty" yaml:"feed_leg,omitempty" mapstructure:"feed_leg,omitempty"` + + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // PowerPort corresponds to the JSON schema field "power_port". + PowerPort *string `json:"power_port,omitempty" yaml:"power_port,omitempty" mapstructure:"power_port,omitempty"` + + // Type corresponds to the JSON schema field "type". + Type DeviceTypePowerOutletsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type DeviceTypePowerOutletsElemFeedLeg string + +const DeviceTypePowerOutletsElemFeedLegA DeviceTypePowerOutletsElemFeedLeg = "A" +const DeviceTypePowerOutletsElemFeedLegB DeviceTypePowerOutletsElemFeedLeg = "B" +const DeviceTypePowerOutletsElemFeedLegC DeviceTypePowerOutletsElemFeedLeg = "C" + +type DeviceTypePowerOutletsElemType string + +const DeviceTypePowerOutletsElemTypeCS6360C DeviceTypePowerOutletsElemType = "CS6360C" +const DeviceTypePowerOutletsElemTypeCS6364C DeviceTypePowerOutletsElemType = "CS6364C" +const DeviceTypePowerOutletsElemTypeCS8164C DeviceTypePowerOutletsElemType = "CS8164C" +const DeviceTypePowerOutletsElemTypeCS8264C DeviceTypePowerOutletsElemType = "CS8264C" +const DeviceTypePowerOutletsElemTypeCS8364C DeviceTypePowerOutletsElemType = "CS8364C" +const DeviceTypePowerOutletsElemTypeCS8464C DeviceTypePowerOutletsElemType = "CS8464C" +const DeviceTypePowerOutletsElemTypeDcTerminal DeviceTypePowerOutletsElemType = "dc-terminal" +const DeviceTypePowerOutletsElemTypeHardwired DeviceTypePowerOutletsElemType = "hardwired" +const DeviceTypePowerOutletsElemTypeHdotCx DeviceTypePowerOutletsElemType = "hdot-cx" +const DeviceTypePowerOutletsElemTypeIec603092PE4H DeviceTypePowerOutletsElemType = "iec-60309-2p-e-4h" +const DeviceTypePowerOutletsElemTypeIec603092PE6H DeviceTypePowerOutletsElemType = "iec-60309-2p-e-6h" +const DeviceTypePowerOutletsElemTypeIec603092PE9H DeviceTypePowerOutletsElemType = "iec-60309-2p-e-9h" +const DeviceTypePowerOutletsElemTypeIec603093PE4H DeviceTypePowerOutletsElemType = "iec-60309-3p-e-4h" +const DeviceTypePowerOutletsElemTypeIec603093PE6H DeviceTypePowerOutletsElemType = "iec-60309-3p-e-6h" +const DeviceTypePowerOutletsElemTypeIec603093PE9H DeviceTypePowerOutletsElemType = "iec-60309-3p-e-9h" +const DeviceTypePowerOutletsElemTypeIec603093PNE4H DeviceTypePowerOutletsElemType = "iec-60309-3p-n-e-4h" +const DeviceTypePowerOutletsElemTypeIec603093PNE6H DeviceTypePowerOutletsElemType = "iec-60309-3p-n-e-6h" +const DeviceTypePowerOutletsElemTypeIec603093PNE9H DeviceTypePowerOutletsElemType = "iec-60309-3p-n-e-9h" +const DeviceTypePowerOutletsElemTypeIec60309PNE4H DeviceTypePowerOutletsElemType = "iec-60309-p-n-e-4h" +const DeviceTypePowerOutletsElemTypeIec60309PNE6H DeviceTypePowerOutletsElemType = "iec-60309-p-n-e-6h" +const DeviceTypePowerOutletsElemTypeIec60309PNE9H DeviceTypePowerOutletsElemType = "iec-60309-p-n-e-9h" +const DeviceTypePowerOutletsElemTypeIec60320C13 DeviceTypePowerOutletsElemType = "iec-60320-c13" +const DeviceTypePowerOutletsElemTypeIec60320C15 DeviceTypePowerOutletsElemType = "iec-60320-c15" +const DeviceTypePowerOutletsElemTypeIec60320C19 DeviceTypePowerOutletsElemType = "iec-60320-c19" +const DeviceTypePowerOutletsElemTypeIec60320C21 DeviceTypePowerOutletsElemType = "iec-60320-c21" +const DeviceTypePowerOutletsElemTypeIec60320C5 DeviceTypePowerOutletsElemType = "iec-60320-c5" +const DeviceTypePowerOutletsElemTypeIec60320C7 DeviceTypePowerOutletsElemType = "iec-60320-c7" +const DeviceTypePowerOutletsElemTypeIec609061 DeviceTypePowerOutletsElemType = "iec-60906-1" +const DeviceTypePowerOutletsElemTypeItaE DeviceTypePowerOutletsElemType = "ita-e" +const DeviceTypePowerOutletsElemTypeItaF DeviceTypePowerOutletsElemType = "ita-f" +const DeviceTypePowerOutletsElemTypeItaG DeviceTypePowerOutletsElemType = "ita-g" +const DeviceTypePowerOutletsElemTypeItaH DeviceTypePowerOutletsElemType = "ita-h" +const DeviceTypePowerOutletsElemTypeItaI DeviceTypePowerOutletsElemType = "ita-i" +const DeviceTypePowerOutletsElemTypeItaJ DeviceTypePowerOutletsElemType = "ita-j" +const DeviceTypePowerOutletsElemTypeItaK DeviceTypePowerOutletsElemType = "ita-k" +const DeviceTypePowerOutletsElemTypeItaL DeviceTypePowerOutletsElemType = "ita-l" +const DeviceTypePowerOutletsElemTypeItaM DeviceTypePowerOutletsElemType = "ita-m" +const DeviceTypePowerOutletsElemTypeItaMultistandard DeviceTypePowerOutletsElemType = "ita-multistandard" +const DeviceTypePowerOutletsElemTypeItaN DeviceTypePowerOutletsElemType = "ita-n" +const DeviceTypePowerOutletsElemTypeItaO DeviceTypePowerOutletsElemType = "ita-o" +const DeviceTypePowerOutletsElemTypeNbr1413610A DeviceTypePowerOutletsElemType = "nbr-14136-10a" +const DeviceTypePowerOutletsElemTypeNbr1413620A DeviceTypePowerOutletsElemType = "nbr-14136-20a" +const DeviceTypePowerOutletsElemTypeNema1030R DeviceTypePowerOutletsElemType = "nema-10-30r" +const DeviceTypePowerOutletsElemTypeNema1050R DeviceTypePowerOutletsElemType = "nema-10-50r" +const DeviceTypePowerOutletsElemTypeNema115R DeviceTypePowerOutletsElemType = "nema-1-15r" +const DeviceTypePowerOutletsElemTypeNema1420R DeviceTypePowerOutletsElemType = "nema-14-20r" +const DeviceTypePowerOutletsElemTypeNema1430R DeviceTypePowerOutletsElemType = "nema-14-30r" +const DeviceTypePowerOutletsElemTypeNema1450R DeviceTypePowerOutletsElemType = "nema-14-50r" +const DeviceTypePowerOutletsElemTypeNema1460R DeviceTypePowerOutletsElemType = "nema-14-60r" +const DeviceTypePowerOutletsElemTypeNema1515R DeviceTypePowerOutletsElemType = "nema-15-15r" +const DeviceTypePowerOutletsElemTypeNema1520R DeviceTypePowerOutletsElemType = "nema-15-20r" +const DeviceTypePowerOutletsElemTypeNema1530R DeviceTypePowerOutletsElemType = "nema-15-30r" +const DeviceTypePowerOutletsElemTypeNema1550R DeviceTypePowerOutletsElemType = "nema-15-50r" +const DeviceTypePowerOutletsElemTypeNema1560R DeviceTypePowerOutletsElemType = "nema-15-60r" +const DeviceTypePowerOutletsElemTypeNema515R DeviceTypePowerOutletsElemType = "nema-5-15r" +const DeviceTypePowerOutletsElemTypeNema520R DeviceTypePowerOutletsElemType = "nema-5-20r" +const DeviceTypePowerOutletsElemTypeNema530R DeviceTypePowerOutletsElemType = "nema-5-30r" +const DeviceTypePowerOutletsElemTypeNema550R DeviceTypePowerOutletsElemType = "nema-5-50r" +const DeviceTypePowerOutletsElemTypeNema615R DeviceTypePowerOutletsElemType = "nema-6-15r" +const DeviceTypePowerOutletsElemTypeNema620R DeviceTypePowerOutletsElemType = "nema-6-20r" +const DeviceTypePowerOutletsElemTypeNema630R DeviceTypePowerOutletsElemType = "nema-6-30r" +const DeviceTypePowerOutletsElemTypeNema650R DeviceTypePowerOutletsElemType = "nema-6-50r" +const DeviceTypePowerOutletsElemTypeNemaL1030R DeviceTypePowerOutletsElemType = "nema-l10-30r" +const DeviceTypePowerOutletsElemTypeNemaL115R DeviceTypePowerOutletsElemType = "nema-l1-15r" +const DeviceTypePowerOutletsElemTypeNemaL1420R DeviceTypePowerOutletsElemType = "nema-l14-20r" +const DeviceTypePowerOutletsElemTypeNemaL1430R DeviceTypePowerOutletsElemType = "nema-l14-30r" +const DeviceTypePowerOutletsElemTypeNemaL1450R DeviceTypePowerOutletsElemType = "nema-l14-50r" +const DeviceTypePowerOutletsElemTypeNemaL1460R DeviceTypePowerOutletsElemType = "nema-l14-60r" +const DeviceTypePowerOutletsElemTypeNemaL1520R DeviceTypePowerOutletsElemType = "nema-l15-20r" +const DeviceTypePowerOutletsElemTypeNemaL1530R DeviceTypePowerOutletsElemType = "nema-l15-30r" +const DeviceTypePowerOutletsElemTypeNemaL1550R DeviceTypePowerOutletsElemType = "nema-l15-50r" +const DeviceTypePowerOutletsElemTypeNemaL1560R DeviceTypePowerOutletsElemType = "nema-l15-60r" +const DeviceTypePowerOutletsElemTypeNemaL2120R DeviceTypePowerOutletsElemType = "nema-l21-20r" +const DeviceTypePowerOutletsElemTypeNemaL2130R DeviceTypePowerOutletsElemType = "nema-l21-30r" +const DeviceTypePowerOutletsElemTypeNemaL2230R DeviceTypePowerOutletsElemType = "nema-l22-30r" +const DeviceTypePowerOutletsElemTypeNemaL515R DeviceTypePowerOutletsElemType = "nema-l5-15r" +const DeviceTypePowerOutletsElemTypeNemaL520R DeviceTypePowerOutletsElemType = "nema-l5-20r" +const DeviceTypePowerOutletsElemTypeNemaL530R DeviceTypePowerOutletsElemType = "nema-l5-30r" +const DeviceTypePowerOutletsElemTypeNemaL550R DeviceTypePowerOutletsElemType = "nema-l5-50r" +const DeviceTypePowerOutletsElemTypeNemaL615R DeviceTypePowerOutletsElemType = "nema-l6-15r" +const DeviceTypePowerOutletsElemTypeNemaL620R DeviceTypePowerOutletsElemType = "nema-l6-20r" +const DeviceTypePowerOutletsElemTypeNemaL630R DeviceTypePowerOutletsElemType = "nema-l6-30r" +const DeviceTypePowerOutletsElemTypeNemaL650R DeviceTypePowerOutletsElemType = "nema-l6-50r" +const DeviceTypePowerOutletsElemTypeNeutrikPowercon20A DeviceTypePowerOutletsElemType = "neutrik-powercon-20a" +const DeviceTypePowerOutletsElemTypeNeutrikPowercon32A DeviceTypePowerOutletsElemType = "neutrik-powercon-32a" +const DeviceTypePowerOutletsElemTypeNeutrikPowerconTrue1 DeviceTypePowerOutletsElemType = "neutrik-powercon-true1" +const DeviceTypePowerOutletsElemTypeNeutrikPowerconTrue1Top DeviceTypePowerOutletsElemType = "neutrik-powercon-true1-top" +const DeviceTypePowerOutletsElemTypeOther DeviceTypePowerOutletsElemType = "other" +const DeviceTypePowerOutletsElemTypeSafDGrid DeviceTypePowerOutletsElemType = "saf-d-grid" +const DeviceTypePowerOutletsElemTypeUbiquitiSmartpower DeviceTypePowerOutletsElemType = "ubiquiti-smartpower" +const DeviceTypePowerOutletsElemTypeUsbA DeviceTypePowerOutletsElemType = "usb-a" +const DeviceTypePowerOutletsElemTypeUsbC DeviceTypePowerOutletsElemType = "usb-c" +const DeviceTypePowerOutletsElemTypeUsbMicroB DeviceTypePowerOutletsElemType = "usb-micro-b" + +type DeviceTypePowerPortsElem struct { + // AllocatedDraw corresponds to the JSON schema field "allocated_draw". + AllocatedDraw *int `json:"allocated_draw,omitempty" yaml:"allocated_draw,omitempty" mapstructure:"allocated_draw,omitempty"` + + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // MaximumDraw corresponds to the JSON schema field "maximum_draw". + MaximumDraw *int `json:"maximum_draw,omitempty" yaml:"maximum_draw,omitempty" mapstructure:"maximum_draw,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // Type corresponds to the JSON schema field "type". + Type DeviceTypePowerPortsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type DeviceTypePowerPortsElemType string + +const DeviceTypePowerPortsElemTypeCs6361C DeviceTypePowerPortsElemType = "cs6361c" +const DeviceTypePowerPortsElemTypeCs6365C DeviceTypePowerPortsElemType = "cs6365c" +const DeviceTypePowerPortsElemTypeCs8165C DeviceTypePowerPortsElemType = "cs8165c" +const DeviceTypePowerPortsElemTypeCs8265C DeviceTypePowerPortsElemType = "cs8265c" +const DeviceTypePowerPortsElemTypeCs8365C DeviceTypePowerPortsElemType = "cs8365c" +const DeviceTypePowerPortsElemTypeCs8465C DeviceTypePowerPortsElemType = "cs8465c" +const DeviceTypePowerPortsElemTypeDcTerminal DeviceTypePowerPortsElemType = "dc-terminal" +const DeviceTypePowerPortsElemTypeHardwired DeviceTypePowerPortsElemType = "hardwired" +const DeviceTypePowerPortsElemTypeIec603092PE4H DeviceTypePowerPortsElemType = "iec-60309-2p-e-4h" +const DeviceTypePowerPortsElemTypeIec603092PE6H DeviceTypePowerPortsElemType = "iec-60309-2p-e-6h" +const DeviceTypePowerPortsElemTypeIec603092PE9H DeviceTypePowerPortsElemType = "iec-60309-2p-e-9h" +const DeviceTypePowerPortsElemTypeIec603093PE4H DeviceTypePowerPortsElemType = "iec-60309-3p-e-4h" +const DeviceTypePowerPortsElemTypeIec603093PE6H DeviceTypePowerPortsElemType = "iec-60309-3p-e-6h" +const DeviceTypePowerPortsElemTypeIec603093PE9H DeviceTypePowerPortsElemType = "iec-60309-3p-e-9h" +const DeviceTypePowerPortsElemTypeIec603093PNE4H DeviceTypePowerPortsElemType = "iec-60309-3p-n-e-4h" +const DeviceTypePowerPortsElemTypeIec603093PNE6H DeviceTypePowerPortsElemType = "iec-60309-3p-n-e-6h" +const DeviceTypePowerPortsElemTypeIec603093PNE9H DeviceTypePowerPortsElemType = "iec-60309-3p-n-e-9h" +const DeviceTypePowerPortsElemTypeIec60309PNE4H DeviceTypePowerPortsElemType = "iec-60309-p-n-e-4h" +const DeviceTypePowerPortsElemTypeIec60309PNE6H DeviceTypePowerPortsElemType = "iec-60309-p-n-e-6h" +const DeviceTypePowerPortsElemTypeIec60309PNE9H DeviceTypePowerPortsElemType = "iec-60309-p-n-e-9h" +const DeviceTypePowerPortsElemTypeIec60320C14 DeviceTypePowerPortsElemType = "iec-60320-c14" +const DeviceTypePowerPortsElemTypeIec60320C16 DeviceTypePowerPortsElemType = "iec-60320-c16" +const DeviceTypePowerPortsElemTypeIec60320C20 DeviceTypePowerPortsElemType = "iec-60320-c20" +const DeviceTypePowerPortsElemTypeIec60320C22 DeviceTypePowerPortsElemType = "iec-60320-c22" +const DeviceTypePowerPortsElemTypeIec60320C6 DeviceTypePowerPortsElemType = "iec-60320-c6" +const DeviceTypePowerPortsElemTypeIec60320C8 DeviceTypePowerPortsElemType = "iec-60320-c8" +const DeviceTypePowerPortsElemTypeIec609061 DeviceTypePowerPortsElemType = "iec-60906-1" +const DeviceTypePowerPortsElemTypeItaC DeviceTypePowerPortsElemType = "ita-c" +const DeviceTypePowerPortsElemTypeItaE DeviceTypePowerPortsElemType = "ita-e" +const DeviceTypePowerPortsElemTypeItaEf DeviceTypePowerPortsElemType = "ita-ef" +const DeviceTypePowerPortsElemTypeItaF DeviceTypePowerPortsElemType = "ita-f" +const DeviceTypePowerPortsElemTypeItaG DeviceTypePowerPortsElemType = "ita-g" +const DeviceTypePowerPortsElemTypeItaH DeviceTypePowerPortsElemType = "ita-h" +const DeviceTypePowerPortsElemTypeItaI DeviceTypePowerPortsElemType = "ita-i" +const DeviceTypePowerPortsElemTypeItaJ DeviceTypePowerPortsElemType = "ita-j" +const DeviceTypePowerPortsElemTypeItaK DeviceTypePowerPortsElemType = "ita-k" +const DeviceTypePowerPortsElemTypeItaL DeviceTypePowerPortsElemType = "ita-l" +const DeviceTypePowerPortsElemTypeItaM DeviceTypePowerPortsElemType = "ita-m" +const DeviceTypePowerPortsElemTypeItaN DeviceTypePowerPortsElemType = "ita-n" +const DeviceTypePowerPortsElemTypeItaO DeviceTypePowerPortsElemType = "ita-o" +const DeviceTypePowerPortsElemTypeNbr1413610A DeviceTypePowerPortsElemType = "nbr-14136-10a" +const DeviceTypePowerPortsElemTypeNbr1413620A DeviceTypePowerPortsElemType = "nbr-14136-20a" +const DeviceTypePowerPortsElemTypeNema1030P DeviceTypePowerPortsElemType = "nema-10-30p" +const DeviceTypePowerPortsElemTypeNema1050P DeviceTypePowerPortsElemType = "nema-10-50p" +const DeviceTypePowerPortsElemTypeNema115P DeviceTypePowerPortsElemType = "nema-1-15p" +const DeviceTypePowerPortsElemTypeNema1420P DeviceTypePowerPortsElemType = "nema-14-20p" +const DeviceTypePowerPortsElemTypeNema1430P DeviceTypePowerPortsElemType = "nema-14-30p" +const DeviceTypePowerPortsElemTypeNema1450P DeviceTypePowerPortsElemType = "nema-14-50p" +const DeviceTypePowerPortsElemTypeNema1460P DeviceTypePowerPortsElemType = "nema-14-60p" +const DeviceTypePowerPortsElemTypeNema1515P DeviceTypePowerPortsElemType = "nema-15-15p" +const DeviceTypePowerPortsElemTypeNema1520P DeviceTypePowerPortsElemType = "nema-15-20p" +const DeviceTypePowerPortsElemTypeNema1530P DeviceTypePowerPortsElemType = "nema-15-30p" +const DeviceTypePowerPortsElemTypeNema1550P DeviceTypePowerPortsElemType = "nema-15-50p" +const DeviceTypePowerPortsElemTypeNema1560P DeviceTypePowerPortsElemType = "nema-15-60p" +const DeviceTypePowerPortsElemTypeNema515P DeviceTypePowerPortsElemType = "nema-5-15p" +const DeviceTypePowerPortsElemTypeNema520P DeviceTypePowerPortsElemType = "nema-5-20p" +const DeviceTypePowerPortsElemTypeNema530P DeviceTypePowerPortsElemType = "nema-5-30p" +const DeviceTypePowerPortsElemTypeNema550P DeviceTypePowerPortsElemType = "nema-5-50p" +const DeviceTypePowerPortsElemTypeNema615P DeviceTypePowerPortsElemType = "nema-6-15p" +const DeviceTypePowerPortsElemTypeNema620P DeviceTypePowerPortsElemType = "nema-6-20p" +const DeviceTypePowerPortsElemTypeNema630P DeviceTypePowerPortsElemType = "nema-6-30p" +const DeviceTypePowerPortsElemTypeNema650P DeviceTypePowerPortsElemType = "nema-6-50p" +const DeviceTypePowerPortsElemTypeNemaL1030P DeviceTypePowerPortsElemType = "nema-l10-30p" +const DeviceTypePowerPortsElemTypeNemaL115P DeviceTypePowerPortsElemType = "nema-l1-15p" +const DeviceTypePowerPortsElemTypeNemaL1420P DeviceTypePowerPortsElemType = "nema-l14-20p" +const DeviceTypePowerPortsElemTypeNemaL1430P DeviceTypePowerPortsElemType = "nema-l14-30p" +const DeviceTypePowerPortsElemTypeNemaL1450P DeviceTypePowerPortsElemType = "nema-l14-50p" +const DeviceTypePowerPortsElemTypeNemaL1460P DeviceTypePowerPortsElemType = "nema-l14-60p" +const DeviceTypePowerPortsElemTypeNemaL1520P DeviceTypePowerPortsElemType = "nema-l15-20p" +const DeviceTypePowerPortsElemTypeNemaL1530P DeviceTypePowerPortsElemType = "nema-l15-30p" +const DeviceTypePowerPortsElemTypeNemaL1550P DeviceTypePowerPortsElemType = "nema-l15-50p" +const DeviceTypePowerPortsElemTypeNemaL1560P DeviceTypePowerPortsElemType = "nema-l15-60p" +const DeviceTypePowerPortsElemTypeNemaL2120P DeviceTypePowerPortsElemType = "nema-l21-20p" +const DeviceTypePowerPortsElemTypeNemaL2130P DeviceTypePowerPortsElemType = "nema-l21-30p" +const DeviceTypePowerPortsElemTypeNemaL2230P DeviceTypePowerPortsElemType = "nema-l22-30p" +const DeviceTypePowerPortsElemTypeNemaL515P DeviceTypePowerPortsElemType = "nema-l5-15p" +const DeviceTypePowerPortsElemTypeNemaL520P DeviceTypePowerPortsElemType = "nema-l5-20p" +const DeviceTypePowerPortsElemTypeNemaL530P DeviceTypePowerPortsElemType = "nema-l5-30p" +const DeviceTypePowerPortsElemTypeNemaL550P DeviceTypePowerPortsElemType = "nema-l5-50p" +const DeviceTypePowerPortsElemTypeNemaL615P DeviceTypePowerPortsElemType = "nema-l6-15p" +const DeviceTypePowerPortsElemTypeNemaL620P DeviceTypePowerPortsElemType = "nema-l6-20p" +const DeviceTypePowerPortsElemTypeNemaL630P DeviceTypePowerPortsElemType = "nema-l6-30p" +const DeviceTypePowerPortsElemTypeNemaL650P DeviceTypePowerPortsElemType = "nema-l6-50p" +const DeviceTypePowerPortsElemTypeNeutrikPowercon20 DeviceTypePowerPortsElemType = "neutrik-powercon-20" +const DeviceTypePowerPortsElemTypeNeutrikPowercon32 DeviceTypePowerPortsElemType = "neutrik-powercon-32" +const DeviceTypePowerPortsElemTypeNeutrikPowerconTrue1 DeviceTypePowerPortsElemType = "neutrik-powercon-true1" +const DeviceTypePowerPortsElemTypeNeutrikPowerconTrue1Top DeviceTypePowerPortsElemType = "neutrik-powercon-true1-top" +const DeviceTypePowerPortsElemTypeOther DeviceTypePowerPortsElemType = "other" +const DeviceTypePowerPortsElemTypeSafDGrid DeviceTypePowerPortsElemType = "saf-d-grid" +const DeviceTypePowerPortsElemTypeUbiquitiSmartpower DeviceTypePowerPortsElemType = "ubiquiti-smartpower" +const DeviceTypePowerPortsElemTypeUsb3B DeviceTypePowerPortsElemType = "usb-3-b" +const DeviceTypePowerPortsElemTypeUsb3MicroB DeviceTypePowerPortsElemType = "usb-3-micro-b" +const DeviceTypePowerPortsElemTypeUsbA DeviceTypePowerPortsElemType = "usb-a" +const DeviceTypePowerPortsElemTypeUsbB DeviceTypePowerPortsElemType = "usb-b" +const DeviceTypePowerPortsElemTypeUsbC DeviceTypePowerPortsElemType = "usb-c" +const DeviceTypePowerPortsElemTypeUsbMicroA DeviceTypePowerPortsElemType = "usb-micro-a" +const DeviceTypePowerPortsElemTypeUsbMicroAb DeviceTypePowerPortsElemType = "usb-micro-ab" +const DeviceTypePowerPortsElemTypeUsbMicroB DeviceTypePowerPortsElemType = "usb-micro-b" +const DeviceTypePowerPortsElemTypeUsbMiniA DeviceTypePowerPortsElemType = "usb-mini-a" +const DeviceTypePowerPortsElemTypeUsbMiniB DeviceTypePowerPortsElemType = "usb-mini-b" + +type DeviceTypeRearPortsElem struct { + // Color corresponds to the JSON schema field "color". + Color *string `json:"color,omitempty" yaml:"color,omitempty" mapstructure:"color,omitempty"` + + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // Poe corresponds to the JSON schema field "poe". + Poe *bool `json:"poe,omitempty" yaml:"poe,omitempty" mapstructure:"poe,omitempty"` + + // Positions corresponds to the JSON schema field "positions". + Positions *int `json:"positions,omitempty" yaml:"positions,omitempty" mapstructure:"positions,omitempty"` + + // Type corresponds to the JSON schema field "type". + Type DeviceTypeRearPortsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type DeviceTypeRearPortsElemType string + +const DeviceTypeRearPortsElemTypeA110Punch DeviceTypeRearPortsElemType = "110-punch" +const DeviceTypeRearPortsElemTypeA4P2C DeviceTypeRearPortsElemType = "4p2c" +const DeviceTypeRearPortsElemTypeA4P4C DeviceTypeRearPortsElemType = "4p4c" +const DeviceTypeRearPortsElemTypeA6P2C DeviceTypeRearPortsElemType = "6p2c" +const DeviceTypeRearPortsElemTypeA6P4C DeviceTypeRearPortsElemType = "6p4c" +const DeviceTypeRearPortsElemTypeA6P6C DeviceTypeRearPortsElemType = "6p6c" +const DeviceTypeRearPortsElemTypeA8P2C DeviceTypeRearPortsElemType = "8p2c" +const DeviceTypeRearPortsElemTypeA8P4C DeviceTypeRearPortsElemType = "8p4c" +const DeviceTypeRearPortsElemTypeA8P6C DeviceTypeRearPortsElemType = "8p6c" +const DeviceTypeRearPortsElemTypeA8P8C DeviceTypeRearPortsElemType = "8p8c" +const DeviceTypeRearPortsElemTypeBnc DeviceTypeRearPortsElemType = "bnc" +const DeviceTypeRearPortsElemTypeCs DeviceTypeRearPortsElemType = "cs" +const DeviceTypeRearPortsElemTypeF DeviceTypeRearPortsElemType = "f" +const DeviceTypeRearPortsElemTypeFc DeviceTypeRearPortsElemType = "fc" +const DeviceTypeRearPortsElemTypeGg45 DeviceTypeRearPortsElemType = "gg45" +const DeviceTypeRearPortsElemTypeLc DeviceTypeRearPortsElemType = "lc" +const DeviceTypeRearPortsElemTypeLcApc DeviceTypeRearPortsElemType = "lc-apc" +const DeviceTypeRearPortsElemTypeLcPc DeviceTypeRearPortsElemType = "lc-pc" +const DeviceTypeRearPortsElemTypeLcUpc DeviceTypeRearPortsElemType = "lc-upc" +const DeviceTypeRearPortsElemTypeLsh DeviceTypeRearPortsElemType = "lsh" +const DeviceTypeRearPortsElemTypeLshApc DeviceTypeRearPortsElemType = "lsh-apc" +const DeviceTypeRearPortsElemTypeLshPc DeviceTypeRearPortsElemType = "lsh-pc" + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeInterfacesElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypeInterfacesElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypeInterfacesElemType, v) + } + *j = DeviceTypeInterfacesElemType(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeInterfacesElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in DeviceTypeInterfacesElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in DeviceTypeInterfacesElem: required") + } + type Plain DeviceTypeInterfacesElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceTypeInterfacesElem(plain) + return nil +} + +var enumValues_DeviceTypePowerOutletsElemFeedLeg = []interface{}{ + "A", + "B", + "C", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypePowerPortsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in DeviceTypePowerPortsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in DeviceTypePowerPortsElem: required") + } + type Plain DeviceTypePowerPortsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceTypePowerPortsElem(plain) + return nil +} + +const DeviceTypeRearPortsElemTypeLx5 DeviceTypeRearPortsElemType = "lx5" + +var enumValues_DeviceTypeRearPortsElemType = []interface{}{ + "8p8c", + "8p6c", + "8p4c", + "8p2c", + "6p6c", + "6p4c", + "6p2c", + "4p4c", + "4p2c", + "gg45", + "tera-4p", + "tera-2p", + "tera-1p", + "110-punch", + "bnc", + "f", + "n", + "mrj21", + "fc", + "lc", + "lc-pc", + "lc-upc", + "lc-apc", + "lsh", + "lsh-pc", + "lsh-upc", + "lsh-apc", + "lx5", + "lx5-pc", + "lx5-upc", + "lx5-apc", + "mpo", + "mtrj", + "sc", + "sc-pc", + "sc-upc", + "sc-apc", + "st", + "cs", + "sn", + "sma-905", + "sma-906", + "urm-p2", + "urm-p4", + "urm-p8", + "splice", + "other", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeRearPortsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypeRearPortsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypeRearPortsElemType, v) + } + *j = DeviceTypeRearPortsElemType(v) + return nil +} + +var enumValues_DeviceTypeInterfacesElemType = []interface{}{ + "virtual", + "bridge", + "lag", + "100base-fx", + "100base-lfx", + "100base-tx", + "100base-t1", + "1000base-t", + "2.5gbase-t", + "5gbase-t", + "10gbase-t", + "10gbase-cx4", + "1000base-x-gbic", + "1000base-x-sfp", + "10gbase-x-sfpp", + "10gbase-x-xfp", + "10gbase-x-xenpak", + "10gbase-x-x2", + "25gbase-x-sfp28", + "50gbase-x-sfp56", + "40gbase-x-qsfpp", + "50gbase-x-sfp28", + "100gbase-x-cfp", + "100gbase-x-cfp2", + "200gbase-x-cfp2", + "400gbase-x-cfp2", + "100gbase-x-cfp4", + "100gbase-x-cxp", + "100gbase-x-cpak", + "100gbase-x-dsfp", + "100gbase-x-sfpdd", + "100gbase-x-qsfp28", + "100gbase-x-qsfpdd", + "200gbase-x-qsfp56", + "200gbase-x-qsfpdd", + "400gbase-x-qsfp112", + "400gbase-x-qsfpdd", + "400gbase-x-osfp", + "400gbase-x-osfp-rhs", + "400gbase-x-cdfp", + "400gbase-x-cfp8", + "800gbase-x-qsfpdd", + "800gbase-x-osfp", + "1000base-kx", + "10gbase-kr", + "10gbase-kx4", + "25gbase-kr", + "40gbase-kr4", + "50gbase-kr", + "100gbase-kp4", + "100gbase-kr2", + "100gbase-kr4", + "ieee802.11a", + "ieee802.11g", + "ieee802.11n", + "ieee802.11ac", + "ieee802.11ad", + "ieee802.11ax", + "ieee802.11ay", + "ieee802.15.1", + "other-wireless", + "gsm", + "cdma", + "lte", + "sonet-oc3", + "sonet-oc12", + "sonet-oc48", + "sonet-oc192", + "sonet-oc768", + "sonet-oc1920", + "sonet-oc3840", + "1gfc-sfp", + "2gfc-sfp", + "4gfc-sfp", + "8gfc-sfpp", + "16gfc-sfpp", + "32gfc-sfp28", + "64gfc-qsfpp", + "128gfc-qsfp28", + "infiniband-sdr", + "infiniband-ddr", + "infiniband-qdr", + "infiniband-fdr10", + "infiniband-fdr", + "infiniband-edr", + "infiniband-hdr", + "infiniband-ndr", + "infiniband-xdr", + "t1", + "e1", + "t3", + "e3", + "xdsl", + "docsis", + "gpon", + "xg-pon", + "xgs-pon", + "ng-pon2", + "epon", + "10g-epon", + "cisco-stackwise", + "cisco-stackwise-plus", + "cisco-flexstack", + "cisco-flexstack-plus", + "cisco-stackwise-80", + "cisco-stackwise-160", + "cisco-stackwise-320", + "cisco-stackwise-480", + "cisco-stackwise-1t", + "juniper-vcp", + "extreme-summitstack", + "extreme-summitstack-128", + "extreme-summitstack-256", + "extreme-summitstack-512", + "other", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeInterfacesElemPoeType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypeInterfacesElemPoeType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypeInterfacesElemPoeType, v) + } + *j = DeviceTypeInterfacesElemPoeType(v) + return nil +} + +var enumValues_DeviceTypeInterfacesElemPoeType = []interface{}{ + "type1-ieee802.3af", + "type2-ieee802.3at", + "type3-ieee802.3bt", + "type4-ieee802.3bt", + "passive-24v-2pair", + "passive-24v-4pair", + "passive-48v-2pair", + "passive-48v-4pair", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeInterfacesElemPoeMode) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypeInterfacesElemPoeMode { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypeInterfacesElemPoeMode, v) + } + *j = DeviceTypeInterfacesElemPoeMode(v) + return nil +} + +var enumValues_DeviceTypeInterfacesElemPoeMode = []interface{}{ + "pd", + "pse", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeFrontPortsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in DeviceTypeFrontPortsElem: required") + } + if v, ok := raw["rear_port"]; !ok || v == nil { + return fmt.Errorf("field rear_port in DeviceTypeFrontPortsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in DeviceTypeFrontPortsElem: required") + } + type Plain DeviceTypeFrontPortsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceTypeFrontPortsElem(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeFrontPortsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypeFrontPortsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypeFrontPortsElemType, v) + } + *j = DeviceTypeFrontPortsElemType(v) + return nil +} + +var enumValues_DeviceTypeFrontPortsElemType = []interface{}{ + "8p8c", + "8p6c", + "8p4c", + "8p2c", + "6p6c", + "6p4c", + "6p2c", + "4p4c", + "4p2c", + "gg45", + "tera-4p", + "tera-2p", + "tera-1p", + "110-punch", + "bnc", + "f", + "n", + "mrj21", + "fc", + "lc", + "lc-pc", + "lc-upc", + "lc-apc", + "lsh", + "lsh-pc", + "lsh-upc", + "lsh-apc", + "lx5", + "lx5-pc", + "lx5-upc", + "lx5-apc", + "mpo", + "mtrj", + "sc", + "sc-pc", + "sc-upc", + "sc-apc", + "st", + "cs", + "sn", + "sma-905", + "sma-906", + "urm-p2", + "urm-p4", + "urm-p8", + "splice", + "other", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeDeviceBaysElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in DeviceTypeDeviceBaysElem: required") + } + type Plain DeviceTypeDeviceBaysElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceTypeDeviceBaysElem(plain) + return nil +} + +var enumValues_DeviceTypeConsolePortsElemType = []interface{}{ + "de-9", + "db-25", + "rj-11", + "rj-12", + "rj-45", + "mini-din-8", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "other", +} + +const DeviceTypeRearPortsElemTypeTera4P DeviceTypeRearPortsElemType = "tera-4p" +const DeviceTypeRearPortsElemTypeTera2P DeviceTypeRearPortsElemType = "tera-2p" +const DeviceTypeRearPortsElemTypeTera1P DeviceTypeRearPortsElemType = "tera-1p" + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeConsoleServerPortsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in DeviceTypeConsoleServerPortsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in DeviceTypeConsoleServerPortsElem: required") + } + type Plain DeviceTypeConsoleServerPortsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceTypeConsoleServerPortsElem(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeConsoleServerPortsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypeConsoleServerPortsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypeConsoleServerPortsElemType, v) + } + *j = DeviceTypeConsoleServerPortsElemType(v) + return nil +} + +var enumValues_DeviceTypeConsoleServerPortsElemType = []interface{}{ + "de-9", + "db-25", + "rj-11", + "rj-12", + "rj-45", + "mini-din-8", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "other", +} + +const DeviceTypeRearPortsElemTypeN DeviceTypeRearPortsElemType = "n" +const DeviceTypeRearPortsElemTypeMrj21 DeviceTypeRearPortsElemType = "mrj21" + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeConsolePortsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in DeviceTypeConsolePortsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in DeviceTypeConsolePortsElem: required") + } + type Plain DeviceTypeConsolePortsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceTypeConsolePortsElem(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeInventoryItemsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in DeviceTypeInventoryItemsElem: required") + } + type Plain DeviceTypeInventoryItemsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceTypeInventoryItemsElem(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeModuleBaysElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in DeviceTypeModuleBaysElem: required") + } + type Plain DeviceTypeModuleBaysElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceTypeModuleBaysElem(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypePowerPortsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypePowerPortsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypePowerPortsElemType, v) + } + *j = DeviceTypePowerPortsElemType(v) + return nil +} + +var enumValues_DeviceTypePowerPortsElemType = []interface{}{ + "iec-60320-c6", + "iec-60320-c8", + "iec-60320-c14", + "iec-60320-c16", + "iec-60320-c20", + "iec-60320-c22", + "iec-60309-p-n-e-4h", + "iec-60309-p-n-e-6h", + "iec-60309-p-n-e-9h", + "iec-60309-2p-e-4h", + "iec-60309-2p-e-6h", + "iec-60309-2p-e-9h", + "iec-60309-3p-e-4h", + "iec-60309-3p-e-6h", + "iec-60309-3p-e-9h", + "iec-60309-3p-n-e-4h", + "iec-60309-3p-n-e-6h", + "iec-60309-3p-n-e-9h", + "iec-60906-1", + "nbr-14136-10a", + "nbr-14136-20a", + "nema-1-15p", + "nema-5-15p", + "nema-5-20p", + "nema-5-30p", + "nema-5-50p", + "nema-6-15p", + "nema-6-20p", + "nema-6-30p", + "nema-6-50p", + "nema-10-30p", + "nema-10-50p", + "nema-14-20p", + "nema-14-30p", + "nema-14-50p", + "nema-14-60p", + "nema-15-15p", + "nema-15-20p", + "nema-15-30p", + "nema-15-50p", + "nema-15-60p", + "nema-l1-15p", + "nema-l5-15p", + "nema-l5-20p", + "nema-l5-30p", + "nema-l5-50p", + "nema-l6-15p", + "nema-l6-20p", + "nema-l6-30p", + "nema-l6-50p", + "nema-l10-30p", + "nema-l14-20p", + "nema-l14-30p", + "nema-l14-50p", + "nema-l14-60p", + "nema-l15-20p", + "nema-l15-30p", + "nema-l15-50p", + "nema-l15-60p", + "nema-l21-20p", + "nema-l21-30p", + "nema-l22-30p", + "cs6361c", + "cs6365c", + "cs8165c", + "cs8265c", + "cs8365c", + "cs8465c", + "ita-c", + "ita-e", + "ita-f", + "ita-ef", + "ita-g", + "ita-h", + "ita-i", + "ita-j", + "ita-k", + "ita-l", + "ita-m", + "ita-n", + "ita-o", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "usb-3-b", + "usb-3-micro-b", + "dc-terminal", + "saf-d-grid", + "neutrik-powercon-20", + "neutrik-powercon-32", + "neutrik-powercon-true1", + "neutrik-powercon-true1-top", + "ubiquiti-smartpower", + "hardwired", + "other", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypePowerOutletsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in DeviceTypePowerOutletsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in DeviceTypePowerOutletsElem: required") + } + type Plain DeviceTypePowerOutletsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceTypePowerOutletsElem(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypePowerOutletsElemFeedLeg) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypePowerOutletsElemFeedLeg { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypePowerOutletsElemFeedLeg, v) + } + *j = DeviceTypePowerOutletsElemFeedLeg(v) + return nil +} + +const DeviceTypeRearPortsElemTypeLshUpc DeviceTypeRearPortsElemType = "lsh-upc" + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypePowerOutletsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypePowerOutletsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypePowerOutletsElemType, v) + } + *j = DeviceTypePowerOutletsElemType(v) + return nil +} + +const DeviceTypeRearPortsElemTypeLx5Pc DeviceTypeRearPortsElemType = "lx5-pc" + +var enumValues_DeviceTypePowerOutletsElemType = []interface{}{ + "iec-60320-c5", + "iec-60320-c7", + "iec-60320-c13", + "iec-60320-c15", + "iec-60320-c19", + "iec-60320-c21", + "iec-60309-p-n-e-4h", + "iec-60309-p-n-e-6h", + "iec-60309-p-n-e-9h", + "iec-60309-2p-e-4h", + "iec-60309-2p-e-6h", + "iec-60309-2p-e-9h", + "iec-60309-3p-e-4h", + "iec-60309-3p-e-6h", + "iec-60309-3p-e-9h", + "iec-60309-3p-n-e-4h", + "iec-60309-3p-n-e-6h", + "iec-60309-3p-n-e-9h", + "iec-60906-1", + "nbr-14136-10a", + "nbr-14136-20a", + "nema-1-15r", + "nema-5-15r", + "nema-5-20r", + "nema-5-30r", + "nema-5-50r", + "nema-6-15r", + "nema-6-20r", + "nema-6-30r", + "nema-6-50r", + "nema-10-30r", + "nema-10-50r", + "nema-14-20r", + "nema-14-30r", + "nema-14-50r", + "nema-14-60r", + "nema-15-15r", + "nema-15-20r", + "nema-15-30r", + "nema-15-50r", + "nema-15-60r", + "nema-l1-15r", + "nema-l5-15r", + "nema-l5-20r", + "nema-l5-30r", + "nema-l5-50r", + "nema-l6-15r", + "nema-l6-20r", + "nema-l6-30r", + "nema-l6-50r", + "nema-l10-30r", + "nema-l14-20r", + "nema-l14-30r", + "nema-l14-50r", + "nema-l14-60r", + "nema-l15-20r", + "nema-l15-30r", + "nema-l15-50r", + "nema-l15-60r", + "nema-l21-20r", + "nema-l21-30r", + "nema-l22-30r", + "CS6360C", + "CS6364C", + "CS8164C", + "CS8264C", + "CS8364C", + "CS8464C", + "ita-e", + "ita-f", + "ita-g", + "ita-h", + "ita-i", + "ita-j", + "ita-k", + "ita-l", + "ita-m", + "ita-n", + "ita-o", + "ita-multistandard", + "usb-a", + "usb-micro-b", + "usb-c", + "dc-terminal", + "hdot-cx", + "saf-d-grid", + "neutrik-powercon-20a", + "neutrik-powercon-32a", + "neutrik-powercon-true1", + "neutrik-powercon-true1-top", + "ubiquiti-smartpower", + "hardwired", + "other", +} + +const DeviceTypeRearPortsElemTypeLx5Upc DeviceTypeRearPortsElemType = "lx5-upc" +const DeviceTypeRearPortsElemTypeLx5Apc DeviceTypeRearPortsElemType = "lx5-apc" +const DeviceTypeRearPortsElemTypeMpo DeviceTypeRearPortsElemType = "mpo" +const DeviceTypeRearPortsElemTypeMtrj DeviceTypeRearPortsElemType = "mtrj" +const DeviceTypeRearPortsElemTypeSc DeviceTypeRearPortsElemType = "sc" +const DeviceTypeRearPortsElemTypeScPc DeviceTypeRearPortsElemType = "sc-pc" +const DeviceTypeRearPortsElemTypeScUpc DeviceTypeRearPortsElemType = "sc-upc" +const DeviceTypeRearPortsElemTypeScApc DeviceTypeRearPortsElemType = "sc-apc" +const DeviceTypeRearPortsElemTypeSt DeviceTypeRearPortsElemType = "st" + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeConsolePortsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypeConsolePortsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypeConsolePortsElemType, v) + } + *j = DeviceTypeConsolePortsElemType(v) + return nil +} + +const DeviceTypeRearPortsElemTypeSn DeviceTypeRearPortsElemType = "sn" +const DeviceTypeRearPortsElemTypeSma905 DeviceTypeRearPortsElemType = "sma-905" +const DeviceTypeRearPortsElemTypeSma906 DeviceTypeRearPortsElemType = "sma-906" +const DeviceTypeRearPortsElemTypeUrmP2 DeviceTypeRearPortsElemType = "urm-p2" +const DeviceTypeRearPortsElemTypeUrmP4 DeviceTypeRearPortsElemType = "urm-p4" +const DeviceTypeRearPortsElemTypeUrmP8 DeviceTypeRearPortsElemType = "urm-p8" +const DeviceTypeRearPortsElemTypeSplice DeviceTypeRearPortsElemType = "splice" +const DeviceTypeRearPortsElemTypeOther DeviceTypeRearPortsElemType = "other" + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeAirflow) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypeAirflow { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypeAirflow, v) + } + *j = DeviceTypeAirflow(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeRearPortsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in DeviceTypeRearPortsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in DeviceTypeRearPortsElem: required") + } + type Plain DeviceTypeRearPortsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceTypeRearPortsElem(plain) + return nil +} + +type DeviceTypeSubdeviceRole string + +var enumValues_DeviceTypeSubdeviceRole = []interface{}{ + "parent", + "child", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeSubdeviceRole) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypeSubdeviceRole { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypeSubdeviceRole, v) + } + *j = DeviceTypeSubdeviceRole(v) + return nil +} + +const DeviceTypeSubdeviceRoleParent DeviceTypeSubdeviceRole = "parent" +const DeviceTypeSubdeviceRoleChild DeviceTypeSubdeviceRole = "child" + +type DeviceTypeWeightUnit string + +var enumValues_DeviceTypeWeightUnit = []interface{}{ + "kg", + "g", + "lb", + "oz", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *DeviceTypeWeightUnit) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_DeviceTypeWeightUnit { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_DeviceTypeWeightUnit, v) + } + *j = DeviceTypeWeightUnit(v) + return nil +} + +const DeviceTypeWeightUnitKg DeviceTypeWeightUnit = "kg" +const DeviceTypeWeightUnitG DeviceTypeWeightUnit = "g" +const DeviceTypeWeightUnitLb DeviceTypeWeightUnit = "lb" +const DeviceTypeWeightUnitOz DeviceTypeWeightUnit = "oz" + +var enumValues_DeviceTypeAirflow = []interface{}{ + "front-to-rear", + "rear-to-front", + "left-to-right", + "right-to-left", + "side-to-rear", + "passive", + "mixed", +} + +// UnmarshalYAML implements json.Unmarshaler. +func (j *DeviceType) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["manufacturer"]; !ok || v == nil { + return fmt.Errorf("field manufacturer in DeviceType: required") + } + if v, ok := raw["model"]; !ok || v == nil { + return fmt.Errorf("field model in DeviceType: required") + } + if v, ok := raw["slug"]; !ok || v == nil { + return fmt.Errorf("field slug in DeviceType: required") + } + type Plain DeviceType + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceType(plain) + return nil +} + +// UnmarshalJSON implements yaml.Unmarshaler. +func (j *DeviceType) UnmarshalYAML(b []byte) error { + var raw map[string]interface{} + if err := yaml.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["manufacturer"]; !ok || v == nil { + return fmt.Errorf("field manufacturer in DeviceType: required") + } + if v, ok := raw["model"]; !ok || v == nil { + return fmt.Errorf("field model in DeviceType: required") + } + if v, ok := raw["slug"]; !ok || v == nil { + return fmt.Errorf("field slug in DeviceType: required") + } + type Plain DeviceType + var plain Plain + if err := yaml.Unmarshal(b, &plain); err != nil { + return err + } + *j = DeviceType(plain) + return nil +} + +func UnmarshalDeviceType(path string) (DeviceType, error) { + deviceType := DeviceType{} + + // unmarshal the file into a devicetype + data, err := os.ReadFile(path) + if err != nil { + return deviceType, err + } + + err = yaml.Unmarshal(data, &deviceType) + if err != nil { + return deviceType, err + } + + return deviceType, nil +} diff --git a/pkg/netbox/types_moduletypes.go b/pkg/netbox/types_moduletypes.go new file mode 100644 index 00000000..0400ebf4 --- /dev/null +++ b/pkg/netbox/types_moduletypes.go @@ -0,0 +1,1569 @@ +/* + * + * MIT License + * + * (C) Copyright 2024 Hewlett Packard Enterprise Development LP + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ +package netbox + +import ( + "encoding/json" + "fmt" + "os" + "reflect" + + "gopkg.in/yaml.v3" +) + +func UnmarshalModuleType(path string) (ModuleType, error) { + moduleType := ModuleType{} + + // unmarshal the file into a devicetype + data, err := os.ReadFile(path) + if err != nil { + return moduleType, err + } + + err = yaml.Unmarshal(data, &moduleType) + if err != nil { + return moduleType, err + } + + return moduleType, nil +} + +type ModuleType struct { + // Comments corresponds to the JSON schema field "comments". + Comments *string `json:"comments,omitempty" yaml:"comments,omitempty" mapstructure:"comments,omitempty"` + + // ConsolePorts corresponds to the JSON schema field "console-ports". + ConsolePorts []ModuleTypeConsolePortsElem `json:"console-ports,omitempty" yaml:"console-ports,omitempty" mapstructure:"console-ports,omitempty"` + + // ConsoleServerPorts corresponds to the JSON schema field "console-server-ports". + ConsoleServerPorts []ModuleTypeConsoleServerPortsElem `json:"console-server-ports,omitempty" yaml:"console-server-ports,omitempty" mapstructure:"console-server-ports,omitempty"` + + // Description corresponds to the JSON schema field "description". + Description *string `json:"description,omitempty" yaml:"description,omitempty" mapstructure:"description,omitempty"` + + // FrontPorts corresponds to the JSON schema field "front-ports". + FrontPorts []ModuleTypeFrontPortsElem `json:"front-ports,omitempty" yaml:"front-ports,omitempty" mapstructure:"front-ports,omitempty"` + + // Interfaces corresponds to the JSON schema field "interfaces". + Interfaces []ModuleTypeInterfacesElem `json:"interfaces,omitempty" yaml:"interfaces,omitempty" mapstructure:"interfaces,omitempty"` + + // Manufacturer corresponds to the JSON schema field "manufacturer". + Manufacturer string `json:"manufacturer" yaml:"manufacturer" mapstructure:"manufacturer"` + + // Model corresponds to the JSON schema field "model". + Model string `json:"model" yaml:"model" mapstructure:"model"` + + // PartNumber corresponds to the JSON schema field "part_number". + PartNumber *string `json:"part_number,omitempty" yaml:"part_number,omitempty" mapstructure:"part_number,omitempty"` + + // PowerOutlets corresponds to the JSON schema field "power-outlets". + PowerOutlets []ModuleTypePowerOutletsElem `json:"power-outlets,omitempty" yaml:"power-outlets,omitempty" mapstructure:"power-outlets,omitempty"` + + // PowerPorts corresponds to the JSON schema field "power-ports". + PowerPorts []ModuleTypePowerPortsElem `json:"power-ports,omitempty" yaml:"power-ports,omitempty" mapstructure:"power-ports,omitempty"` + + // RearPorts corresponds to the JSON schema field "rear-ports". + RearPorts []ModuleTypeRearPortsElem `json:"rear-ports,omitempty" yaml:"rear-ports,omitempty" mapstructure:"rear-ports,omitempty"` + + // Weight corresponds to the JSON schema field "weight". + Weight *float64 `json:"weight,omitempty" yaml:"weight,omitempty" mapstructure:"weight,omitempty"` + + // WeightUnit corresponds to the JSON schema field "weight_unit". + WeightUnit *ModuleTypeWeightUnit `json:"weight_unit,omitempty" yaml:"weight_unit,omitempty" mapstructure:"weight_unit,omitempty"` +} + +type ModuleTypeConsolePortsElem struct { + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // Poe corresponds to the JSON schema field "poe". + Poe *bool `json:"poe,omitempty" yaml:"poe,omitempty" mapstructure:"poe,omitempty"` + + // Type corresponds to the JSON schema field "type". + Type ModuleTypeConsolePortsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type ModuleTypeConsolePortsElemType string + +const ModuleTypeConsolePortsElemTypeDb25 ModuleTypeConsolePortsElemType = "db-25" +const ModuleTypeConsolePortsElemTypeDe9 ModuleTypeConsolePortsElemType = "de-9" +const ModuleTypeConsolePortsElemTypeMiniDin8 ModuleTypeConsolePortsElemType = "mini-din-8" +const ModuleTypeConsolePortsElemTypeOther ModuleTypeConsolePortsElemType = "other" +const ModuleTypeConsolePortsElemTypeRj11 ModuleTypeConsolePortsElemType = "rj-11" +const ModuleTypeConsolePortsElemTypeRj12 ModuleTypeConsolePortsElemType = "rj-12" +const ModuleTypeConsolePortsElemTypeRj45 ModuleTypeConsolePortsElemType = "rj-45" +const ModuleTypeConsolePortsElemTypeUsbA ModuleTypeConsolePortsElemType = "usb-a" +const ModuleTypeConsolePortsElemTypeUsbB ModuleTypeConsolePortsElemType = "usb-b" +const ModuleTypeConsolePortsElemTypeUsbC ModuleTypeConsolePortsElemType = "usb-c" +const ModuleTypeConsolePortsElemTypeUsbMicroA ModuleTypeConsolePortsElemType = "usb-micro-a" +const ModuleTypeConsolePortsElemTypeUsbMicroAb ModuleTypeConsolePortsElemType = "usb-micro-ab" +const ModuleTypeConsolePortsElemTypeUsbMicroB ModuleTypeConsolePortsElemType = "usb-micro-b" +const ModuleTypeConsolePortsElemTypeUsbMiniA ModuleTypeConsolePortsElemType = "usb-mini-a" +const ModuleTypeConsolePortsElemTypeUsbMiniB ModuleTypeConsolePortsElemType = "usb-mini-b" + +type ModuleTypeConsoleServerPortsElem struct { + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // Type corresponds to the JSON schema field "type". + Type ModuleTypeConsoleServerPortsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type ModuleTypeConsoleServerPortsElemType string + +const ModuleTypeConsoleServerPortsElemTypeDb25 ModuleTypeConsoleServerPortsElemType = "db-25" +const ModuleTypeConsoleServerPortsElemTypeDe9 ModuleTypeConsoleServerPortsElemType = "de-9" +const ModuleTypeConsoleServerPortsElemTypeMiniDin8 ModuleTypeConsoleServerPortsElemType = "mini-din-8" +const ModuleTypeConsoleServerPortsElemTypeOther ModuleTypeConsoleServerPortsElemType = "other" +const ModuleTypeConsoleServerPortsElemTypeRj11 ModuleTypeConsoleServerPortsElemType = "rj-11" +const ModuleTypeConsoleServerPortsElemTypeRj12 ModuleTypeConsoleServerPortsElemType = "rj-12" +const ModuleTypeConsoleServerPortsElemTypeRj45 ModuleTypeConsoleServerPortsElemType = "rj-45" +const ModuleTypeConsoleServerPortsElemTypeUsbA ModuleTypeConsoleServerPortsElemType = "usb-a" +const ModuleTypeConsoleServerPortsElemTypeUsbB ModuleTypeConsoleServerPortsElemType = "usb-b" +const ModuleTypeConsoleServerPortsElemTypeUsbC ModuleTypeConsoleServerPortsElemType = "usb-c" +const ModuleTypeConsoleServerPortsElemTypeUsbMicroA ModuleTypeConsoleServerPortsElemType = "usb-micro-a" +const ModuleTypeConsoleServerPortsElemTypeUsbMicroAb ModuleTypeConsoleServerPortsElemType = "usb-micro-ab" +const ModuleTypeConsoleServerPortsElemTypeUsbMicroB ModuleTypeConsoleServerPortsElemType = "usb-micro-b" +const ModuleTypeConsoleServerPortsElemTypeUsbMiniA ModuleTypeConsoleServerPortsElemType = "usb-mini-a" +const ModuleTypeConsoleServerPortsElemTypeUsbMiniB ModuleTypeConsoleServerPortsElemType = "usb-mini-b" + +type ModuleTypeFrontPortsElem struct { + // Color corresponds to the JSON schema field "color". + Color *string `json:"color,omitempty" yaml:"color,omitempty" mapstructure:"color,omitempty"` + + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // RearPort corresponds to the JSON schema field "rear_port". + RearPort string `json:"rear_port" yaml:"rear_port" mapstructure:"rear_port"` + + // RearPortPosition corresponds to the JSON schema field "rear_port_position". + RearPortPosition *int `json:"rear_port_position,omitempty" yaml:"rear_port_position,omitempty" mapstructure:"rear_port_position,omitempty"` + + // Type corresponds to the JSON schema field "type". + Type ModuleTypeFrontPortsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type ModuleTypeFrontPortsElemType string + +const ModuleTypeFrontPortsElemTypeA110Punch ModuleTypeFrontPortsElemType = "110-punch" +const ModuleTypeFrontPortsElemTypeA4P2C ModuleTypeFrontPortsElemType = "4p2c" +const ModuleTypeFrontPortsElemTypeA4P4C ModuleTypeFrontPortsElemType = "4p4c" +const ModuleTypeFrontPortsElemTypeA6P2C ModuleTypeFrontPortsElemType = "6p2c" +const ModuleTypeFrontPortsElemTypeA6P4C ModuleTypeFrontPortsElemType = "6p4c" +const ModuleTypeFrontPortsElemTypeA6P6C ModuleTypeFrontPortsElemType = "6p6c" +const ModuleTypeFrontPortsElemTypeA8P2C ModuleTypeFrontPortsElemType = "8p2c" +const ModuleTypeFrontPortsElemTypeA8P4C ModuleTypeFrontPortsElemType = "8p4c" +const ModuleTypeFrontPortsElemTypeA8P6C ModuleTypeFrontPortsElemType = "8p6c" +const ModuleTypeFrontPortsElemTypeA8P8C ModuleTypeFrontPortsElemType = "8p8c" +const ModuleTypeFrontPortsElemTypeBnc ModuleTypeFrontPortsElemType = "bnc" +const ModuleTypeFrontPortsElemTypeCs ModuleTypeFrontPortsElemType = "cs" +const ModuleTypeFrontPortsElemTypeF ModuleTypeFrontPortsElemType = "f" +const ModuleTypeFrontPortsElemTypeFc ModuleTypeFrontPortsElemType = "fc" +const ModuleTypeFrontPortsElemTypeGg45 ModuleTypeFrontPortsElemType = "gg45" +const ModuleTypeFrontPortsElemTypeLc ModuleTypeFrontPortsElemType = "lc" +const ModuleTypeFrontPortsElemTypeLcApc ModuleTypeFrontPortsElemType = "lc-apc" +const ModuleTypeFrontPortsElemTypeLcPc ModuleTypeFrontPortsElemType = "lc-pc" +const ModuleTypeFrontPortsElemTypeLcUpc ModuleTypeFrontPortsElemType = "lc-upc" +const ModuleTypeFrontPortsElemTypeLsh ModuleTypeFrontPortsElemType = "lsh" +const ModuleTypeFrontPortsElemTypeLshApc ModuleTypeFrontPortsElemType = "lsh-apc" +const ModuleTypeFrontPortsElemTypeLshPc ModuleTypeFrontPortsElemType = "lsh-pc" +const ModuleTypeFrontPortsElemTypeLshUpc ModuleTypeFrontPortsElemType = "lsh-upc" +const ModuleTypeFrontPortsElemTypeLx5 ModuleTypeFrontPortsElemType = "lx5" +const ModuleTypeFrontPortsElemTypeLx5Apc ModuleTypeFrontPortsElemType = "lx5-apc" +const ModuleTypeFrontPortsElemTypeLx5Pc ModuleTypeFrontPortsElemType = "lx5-pc" +const ModuleTypeFrontPortsElemTypeLx5Upc ModuleTypeFrontPortsElemType = "lx5-upc" +const ModuleTypeFrontPortsElemTypeMpo ModuleTypeFrontPortsElemType = "mpo" +const ModuleTypeFrontPortsElemTypeMrj21 ModuleTypeFrontPortsElemType = "mrj21" +const ModuleTypeFrontPortsElemTypeMtrj ModuleTypeFrontPortsElemType = "mtrj" +const ModuleTypeFrontPortsElemTypeN ModuleTypeFrontPortsElemType = "n" +const ModuleTypeFrontPortsElemTypeOther ModuleTypeFrontPortsElemType = "other" +const ModuleTypeFrontPortsElemTypeSc ModuleTypeFrontPortsElemType = "sc" +const ModuleTypeFrontPortsElemTypeScApc ModuleTypeFrontPortsElemType = "sc-apc" +const ModuleTypeFrontPortsElemTypeScPc ModuleTypeFrontPortsElemType = "sc-pc" +const ModuleTypeFrontPortsElemTypeScUpc ModuleTypeFrontPortsElemType = "sc-upc" +const ModuleTypeFrontPortsElemTypeSma905 ModuleTypeFrontPortsElemType = "sma-905" +const ModuleTypeFrontPortsElemTypeSma906 ModuleTypeFrontPortsElemType = "sma-906" +const ModuleTypeFrontPortsElemTypeSn ModuleTypeFrontPortsElemType = "sn" +const ModuleTypeFrontPortsElemTypeSplice ModuleTypeFrontPortsElemType = "splice" +const ModuleTypeFrontPortsElemTypeSt ModuleTypeFrontPortsElemType = "st" +const ModuleTypeFrontPortsElemTypeTera1P ModuleTypeFrontPortsElemType = "tera-1p" +const ModuleTypeFrontPortsElemTypeTera2P ModuleTypeFrontPortsElemType = "tera-2p" +const ModuleTypeFrontPortsElemTypeTera4P ModuleTypeFrontPortsElemType = "tera-4p" +const ModuleTypeFrontPortsElemTypeUrmP2 ModuleTypeFrontPortsElemType = "urm-p2" +const ModuleTypeFrontPortsElemTypeUrmP4 ModuleTypeFrontPortsElemType = "urm-p4" +const ModuleTypeFrontPortsElemTypeUrmP8 ModuleTypeFrontPortsElemType = "urm-p8" + +type ModuleTypeInterfacesElem struct { + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // MgmtOnly corresponds to the JSON schema field "mgmt_only". + MgmtOnly *bool `json:"mgmt_only,omitempty" yaml:"mgmt_only,omitempty" mapstructure:"mgmt_only,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // PoeMode corresponds to the JSON schema field "poe_mode". + PoeMode *ModuleTypeInterfacesElemPoeMode `json:"poe_mode,omitempty" yaml:"poe_mode,omitempty" mapstructure:"poe_mode,omitempty"` + + // PoeType corresponds to the JSON schema field "poe_type". + PoeType *ModuleTypeInterfacesElemPoeType `json:"poe_type,omitempty" yaml:"poe_type,omitempty" mapstructure:"poe_type,omitempty"` + + // Type corresponds to the JSON schema field "type". + Type ModuleTypeInterfacesElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type ModuleTypeInterfacesElemPoeMode string + +const ModuleTypeInterfacesElemPoeModePd ModuleTypeInterfacesElemPoeMode = "pd" +const ModuleTypeInterfacesElemPoeModePse ModuleTypeInterfacesElemPoeMode = "pse" + +type ModuleTypeInterfacesElemPoeType string + +const ModuleTypeInterfacesElemPoeTypePassive24V2Pair ModuleTypeInterfacesElemPoeType = "passive-24v-2pair" +const ModuleTypeInterfacesElemPoeTypePassive24V4Pair ModuleTypeInterfacesElemPoeType = "passive-24v-4pair" +const ModuleTypeInterfacesElemPoeTypePassive48V2Pair ModuleTypeInterfacesElemPoeType = "passive-48v-2pair" +const ModuleTypeInterfacesElemPoeTypePassive48V4Pair ModuleTypeInterfacesElemPoeType = "passive-48v-4pair" +const ModuleTypeInterfacesElemPoeTypeType1Ieee8023Af ModuleTypeInterfacesElemPoeType = "type1-ieee802.3af" +const ModuleTypeInterfacesElemPoeTypeType2Ieee8023At ModuleTypeInterfacesElemPoeType = "type2-ieee802.3at" +const ModuleTypeInterfacesElemPoeTypeType3Ieee8023Bt ModuleTypeInterfacesElemPoeType = "type3-ieee802.3bt" +const ModuleTypeInterfacesElemPoeTypeType4Ieee8023Bt ModuleTypeInterfacesElemPoeType = "type4-ieee802.3bt" + +type ModuleTypeInterfacesElemType string + +const ModuleTypeInterfacesElemTypeA1000BaseKx ModuleTypeInterfacesElemType = "1000base-kx" +const ModuleTypeInterfacesElemTypeA1000BaseT ModuleTypeInterfacesElemType = "1000base-t" +const ModuleTypeInterfacesElemTypeA1000BaseXGbic ModuleTypeInterfacesElemType = "1000base-x-gbic" +const ModuleTypeInterfacesElemTypeA1000BaseXSfp ModuleTypeInterfacesElemType = "1000base-x-sfp" +const ModuleTypeInterfacesElemTypeA100BaseFx ModuleTypeInterfacesElemType = "100base-fx" +const ModuleTypeInterfacesElemTypeA100BaseLfx ModuleTypeInterfacesElemType = "100base-lfx" +const ModuleTypeInterfacesElemTypeA100BaseT1 ModuleTypeInterfacesElemType = "100base-t1" +const ModuleTypeInterfacesElemTypeA100BaseTx ModuleTypeInterfacesElemType = "100base-tx" +const ModuleTypeInterfacesElemTypeA100GbaseKp4 ModuleTypeInterfacesElemType = "100gbase-kp4" +const ModuleTypeInterfacesElemTypeA100GbaseKr2 ModuleTypeInterfacesElemType = "100gbase-kr2" +const ModuleTypeInterfacesElemTypeA100GbaseKr4 ModuleTypeInterfacesElemType = "100gbase-kr4" +const ModuleTypeInterfacesElemTypeA100GbaseXCfp ModuleTypeInterfacesElemType = "100gbase-x-cfp" +const ModuleTypeInterfacesElemTypeA100GbaseXCfp2 ModuleTypeInterfacesElemType = "100gbase-x-cfp2" +const ModuleTypeInterfacesElemTypeA100GbaseXCfp4 ModuleTypeInterfacesElemType = "100gbase-x-cfp4" +const ModuleTypeInterfacesElemTypeA100GbaseXCpak ModuleTypeInterfacesElemType = "100gbase-x-cpak" +const ModuleTypeInterfacesElemTypeA100GbaseXCxp ModuleTypeInterfacesElemType = "100gbase-x-cxp" +const ModuleTypeInterfacesElemTypeA100GbaseXDsfp ModuleTypeInterfacesElemType = "100gbase-x-dsfp" +const ModuleTypeInterfacesElemTypeA100GbaseXQsfp28 ModuleTypeInterfacesElemType = "100gbase-x-qsfp28" +const ModuleTypeInterfacesElemTypeA100GbaseXQsfpdd ModuleTypeInterfacesElemType = "100gbase-x-qsfpdd" +const ModuleTypeInterfacesElemTypeA100GbaseXSfpdd ModuleTypeInterfacesElemType = "100gbase-x-sfpdd" +const ModuleTypeInterfacesElemTypeA10GEpon ModuleTypeInterfacesElemType = "10g-epon" +const ModuleTypeInterfacesElemTypeA10GbaseCx4 ModuleTypeInterfacesElemType = "10gbase-cx4" +const ModuleTypeInterfacesElemTypeA10GbaseKr ModuleTypeInterfacesElemType = "10gbase-kr" +const ModuleTypeInterfacesElemTypeA10GbaseKx4 ModuleTypeInterfacesElemType = "10gbase-kx4" +const ModuleTypeInterfacesElemTypeA10GbaseT ModuleTypeInterfacesElemType = "10gbase-t" +const ModuleTypeInterfacesElemTypeA10GbaseXSfpp ModuleTypeInterfacesElemType = "10gbase-x-sfpp" +const ModuleTypeInterfacesElemTypeA10GbaseXX2 ModuleTypeInterfacesElemType = "10gbase-x-x2" +const ModuleTypeInterfacesElemTypeA10GbaseXXenpak ModuleTypeInterfacesElemType = "10gbase-x-xenpak" +const ModuleTypeInterfacesElemTypeA10GbaseXXfp ModuleTypeInterfacesElemType = "10gbase-x-xfp" +const ModuleTypeInterfacesElemTypeA128GfcQsfp28 ModuleTypeInterfacesElemType = "128gfc-qsfp28" +const ModuleTypeInterfacesElemTypeA16GfcSfpp ModuleTypeInterfacesElemType = "16gfc-sfpp" +const ModuleTypeInterfacesElemTypeA1GfcSfp ModuleTypeInterfacesElemType = "1gfc-sfp" +const ModuleTypeInterfacesElemTypeA200GbaseXCfp2 ModuleTypeInterfacesElemType = "200gbase-x-cfp2" +const ModuleTypeInterfacesElemTypeA200GbaseXQsfp56 ModuleTypeInterfacesElemType = "200gbase-x-qsfp56" +const ModuleTypeInterfacesElemTypeA200GbaseXQsfpdd ModuleTypeInterfacesElemType = "200gbase-x-qsfpdd" +const ModuleTypeInterfacesElemTypeA25GbaseKr ModuleTypeInterfacesElemType = "25gbase-kr" +const ModuleTypeInterfacesElemTypeA25GbaseT ModuleTypeInterfacesElemType = "2.5gbase-t" +const ModuleTypeInterfacesElemTypeA25GbaseXSfp28 ModuleTypeInterfacesElemType = "25gbase-x-sfp28" +const ModuleTypeInterfacesElemTypeA2GfcSfp ModuleTypeInterfacesElemType = "2gfc-sfp" +const ModuleTypeInterfacesElemTypeA32GfcSfp28 ModuleTypeInterfacesElemType = "32gfc-sfp28" +const ModuleTypeInterfacesElemTypeA400GbaseXCdfp ModuleTypeInterfacesElemType = "400gbase-x-cdfp" +const ModuleTypeInterfacesElemTypeA400GbaseXCfp2 ModuleTypeInterfacesElemType = "400gbase-x-cfp2" +const ModuleTypeInterfacesElemTypeA400GbaseXCfp8 ModuleTypeInterfacesElemType = "400gbase-x-cfp8" +const ModuleTypeInterfacesElemTypeA400GbaseXOsfp ModuleTypeInterfacesElemType = "400gbase-x-osfp" +const ModuleTypeInterfacesElemTypeA400GbaseXOsfpRhs ModuleTypeInterfacesElemType = "400gbase-x-osfp-rhs" +const ModuleTypeInterfacesElemTypeA400GbaseXQsfp112 ModuleTypeInterfacesElemType = "400gbase-x-qsfp112" +const ModuleTypeInterfacesElemTypeA400GbaseXQsfpdd ModuleTypeInterfacesElemType = "400gbase-x-qsfpdd" +const ModuleTypeInterfacesElemTypeA40GbaseKr4 ModuleTypeInterfacesElemType = "40gbase-kr4" +const ModuleTypeInterfacesElemTypeA40GbaseXQsfpp ModuleTypeInterfacesElemType = "40gbase-x-qsfpp" +const ModuleTypeInterfacesElemTypeA4GfcSfp ModuleTypeInterfacesElemType = "4gfc-sfp" +const ModuleTypeInterfacesElemTypeA50GbaseKr ModuleTypeInterfacesElemType = "50gbase-kr" +const ModuleTypeInterfacesElemTypeA50GbaseXSfp28 ModuleTypeInterfacesElemType = "50gbase-x-sfp28" +const ModuleTypeInterfacesElemTypeA50GbaseXSfp56 ModuleTypeInterfacesElemType = "50gbase-x-sfp56" +const ModuleTypeInterfacesElemTypeA5GbaseT ModuleTypeInterfacesElemType = "5gbase-t" +const ModuleTypeInterfacesElemTypeA64GfcQsfpp ModuleTypeInterfacesElemType = "64gfc-qsfpp" +const ModuleTypeInterfacesElemTypeA800GbaseXOsfp ModuleTypeInterfacesElemType = "800gbase-x-osfp" +const ModuleTypeInterfacesElemTypeA800GbaseXQsfpdd ModuleTypeInterfacesElemType = "800gbase-x-qsfpdd" +const ModuleTypeInterfacesElemTypeA8GfcSfpp ModuleTypeInterfacesElemType = "8gfc-sfpp" +const ModuleTypeInterfacesElemTypeBridge ModuleTypeInterfacesElemType = "bridge" +const ModuleTypeInterfacesElemTypeCdma ModuleTypeInterfacesElemType = "cdma" +const ModuleTypeInterfacesElemTypeCiscoFlexstack ModuleTypeInterfacesElemType = "cisco-flexstack" +const ModuleTypeInterfacesElemTypeCiscoFlexstackPlus ModuleTypeInterfacesElemType = "cisco-flexstack-plus" +const ModuleTypeInterfacesElemTypeCiscoStackwise ModuleTypeInterfacesElemType = "cisco-stackwise" +const ModuleTypeInterfacesElemTypeCiscoStackwise160 ModuleTypeInterfacesElemType = "cisco-stackwise-160" +const ModuleTypeInterfacesElemTypeCiscoStackwise1T ModuleTypeInterfacesElemType = "cisco-stackwise-1t" +const ModuleTypeInterfacesElemTypeCiscoStackwise320 ModuleTypeInterfacesElemType = "cisco-stackwise-320" +const ModuleTypeInterfacesElemTypeCiscoStackwise480 ModuleTypeInterfacesElemType = "cisco-stackwise-480" +const ModuleTypeInterfacesElemTypeCiscoStackwise80 ModuleTypeInterfacesElemType = "cisco-stackwise-80" +const ModuleTypeInterfacesElemTypeCiscoStackwisePlus ModuleTypeInterfacesElemType = "cisco-stackwise-plus" +const ModuleTypeInterfacesElemTypeDocsis ModuleTypeInterfacesElemType = "docsis" +const ModuleTypeInterfacesElemTypeE1 ModuleTypeInterfacesElemType = "e1" +const ModuleTypeInterfacesElemTypeE3 ModuleTypeInterfacesElemType = "e3" +const ModuleTypeInterfacesElemTypeEpon ModuleTypeInterfacesElemType = "epon" +const ModuleTypeInterfacesElemTypeExtremeSummitstack ModuleTypeInterfacesElemType = "extreme-summitstack" +const ModuleTypeInterfacesElemTypeExtremeSummitstack128 ModuleTypeInterfacesElemType = "extreme-summitstack-128" +const ModuleTypeInterfacesElemTypeExtremeSummitstack256 ModuleTypeInterfacesElemType = "extreme-summitstack-256" +const ModuleTypeInterfacesElemTypeExtremeSummitstack512 ModuleTypeInterfacesElemType = "extreme-summitstack-512" +const ModuleTypeInterfacesElemTypeGpon ModuleTypeInterfacesElemType = "gpon" +const ModuleTypeInterfacesElemTypeGsm ModuleTypeInterfacesElemType = "gsm" +const ModuleTypeInterfacesElemTypeIeee80211A ModuleTypeInterfacesElemType = "ieee802.11a" +const ModuleTypeInterfacesElemTypeIeee80211Ac ModuleTypeInterfacesElemType = "ieee802.11ac" +const ModuleTypeInterfacesElemTypeIeee80211Ad ModuleTypeInterfacesElemType = "ieee802.11ad" +const ModuleTypeInterfacesElemTypeIeee80211Ax ModuleTypeInterfacesElemType = "ieee802.11ax" +const ModuleTypeInterfacesElemTypeIeee80211Ay ModuleTypeInterfacesElemType = "ieee802.11ay" +const ModuleTypeInterfacesElemTypeIeee80211G ModuleTypeInterfacesElemType = "ieee802.11g" +const ModuleTypeInterfacesElemTypeIeee80211N ModuleTypeInterfacesElemType = "ieee802.11n" +const ModuleTypeInterfacesElemTypeIeee802151 ModuleTypeInterfacesElemType = "ieee802.15.1" +const ModuleTypeInterfacesElemTypeInfinibandDdr ModuleTypeInterfacesElemType = "infiniband-ddr" +const ModuleTypeInterfacesElemTypeInfinibandEdr ModuleTypeInterfacesElemType = "infiniband-edr" +const ModuleTypeInterfacesElemTypeInfinibandFdr ModuleTypeInterfacesElemType = "infiniband-fdr" +const ModuleTypeInterfacesElemTypeInfinibandFdr10 ModuleTypeInterfacesElemType = "infiniband-fdr10" +const ModuleTypeInterfacesElemTypeInfinibandHdr ModuleTypeInterfacesElemType = "infiniband-hdr" +const ModuleTypeInterfacesElemTypeInfinibandNdr ModuleTypeInterfacesElemType = "infiniband-ndr" +const ModuleTypeInterfacesElemTypeInfinibandQdr ModuleTypeInterfacesElemType = "infiniband-qdr" +const ModuleTypeInterfacesElemTypeInfinibandSdr ModuleTypeInterfacesElemType = "infiniband-sdr" +const ModuleTypeInterfacesElemTypeInfinibandXdr ModuleTypeInterfacesElemType = "infiniband-xdr" +const ModuleTypeInterfacesElemTypeJuniperVcp ModuleTypeInterfacesElemType = "juniper-vcp" +const ModuleTypeInterfacesElemTypeLag ModuleTypeInterfacesElemType = "lag" +const ModuleTypeInterfacesElemTypeLte ModuleTypeInterfacesElemType = "lte" +const ModuleTypeInterfacesElemTypeNgPon2 ModuleTypeInterfacesElemType = "ng-pon2" +const ModuleTypeInterfacesElemTypeOther ModuleTypeInterfacesElemType = "other" +const ModuleTypeInterfacesElemTypeOtherWireless ModuleTypeInterfacesElemType = "other-wireless" +const ModuleTypeInterfacesElemTypeSonetOc12 ModuleTypeInterfacesElemType = "sonet-oc12" +const ModuleTypeInterfacesElemTypeSonetOc192 ModuleTypeInterfacesElemType = "sonet-oc192" +const ModuleTypeInterfacesElemTypeSonetOc1920 ModuleTypeInterfacesElemType = "sonet-oc1920" +const ModuleTypeInterfacesElemTypeSonetOc3 ModuleTypeInterfacesElemType = "sonet-oc3" +const ModuleTypeInterfacesElemTypeSonetOc3840 ModuleTypeInterfacesElemType = "sonet-oc3840" +const ModuleTypeInterfacesElemTypeSonetOc48 ModuleTypeInterfacesElemType = "sonet-oc48" +const ModuleTypeInterfacesElemTypeSonetOc768 ModuleTypeInterfacesElemType = "sonet-oc768" +const ModuleTypeInterfacesElemTypeT1 ModuleTypeInterfacesElemType = "t1" +const ModuleTypeInterfacesElemTypeT3 ModuleTypeInterfacesElemType = "t3" +const ModuleTypeInterfacesElemTypeVirtual ModuleTypeInterfacesElemType = "virtual" +const ModuleTypeInterfacesElemTypeXdsl ModuleTypeInterfacesElemType = "xdsl" +const ModuleTypeInterfacesElemTypeXgPon ModuleTypeInterfacesElemType = "xg-pon" +const ModuleTypeInterfacesElemTypeXgsPon ModuleTypeInterfacesElemType = "xgs-pon" + +type ModuleTypePowerOutletsElem struct { + // FeedLeg corresponds to the JSON schema field "feed_leg". + FeedLeg *ModuleTypePowerOutletsElemFeedLeg `json:"feed_leg,omitempty" yaml:"feed_leg,omitempty" mapstructure:"feed_leg,omitempty"` + + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // PowerPort corresponds to the JSON schema field "power_port". + PowerPort *string `json:"power_port,omitempty" yaml:"power_port,omitempty" mapstructure:"power_port,omitempty"` + + // Type corresponds to the JSON schema field "type". + Type ModuleTypePowerOutletsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type ModuleTypePowerOutletsElemFeedLeg string + +const ModuleTypePowerOutletsElemFeedLegA ModuleTypePowerOutletsElemFeedLeg = "A" +const ModuleTypePowerOutletsElemFeedLegB ModuleTypePowerOutletsElemFeedLeg = "B" +const ModuleTypePowerOutletsElemFeedLegC ModuleTypePowerOutletsElemFeedLeg = "C" + +type ModuleTypePowerOutletsElemType string + +const ModuleTypePowerOutletsElemTypeCS6360C ModuleTypePowerOutletsElemType = "CS6360C" +const ModuleTypePowerOutletsElemTypeCS6364C ModuleTypePowerOutletsElemType = "CS6364C" +const ModuleTypePowerOutletsElemTypeCS8164C ModuleTypePowerOutletsElemType = "CS8164C" +const ModuleTypePowerOutletsElemTypeCS8264C ModuleTypePowerOutletsElemType = "CS8264C" +const ModuleTypePowerOutletsElemTypeCS8364C ModuleTypePowerOutletsElemType = "CS8364C" +const ModuleTypePowerOutletsElemTypeCS8464C ModuleTypePowerOutletsElemType = "CS8464C" +const ModuleTypePowerOutletsElemTypeDcTerminal ModuleTypePowerOutletsElemType = "dc-terminal" +const ModuleTypePowerOutletsElemTypeHardwired ModuleTypePowerOutletsElemType = "hardwired" +const ModuleTypePowerOutletsElemTypeHdotCx ModuleTypePowerOutletsElemType = "hdot-cx" +const ModuleTypePowerOutletsElemTypeIec603092PE4H ModuleTypePowerOutletsElemType = "iec-60309-2p-e-4h" +const ModuleTypePowerOutletsElemTypeIec603092PE6H ModuleTypePowerOutletsElemType = "iec-60309-2p-e-6h" +const ModuleTypePowerOutletsElemTypeIec603092PE9H ModuleTypePowerOutletsElemType = "iec-60309-2p-e-9h" +const ModuleTypePowerOutletsElemTypeIec603093PE4H ModuleTypePowerOutletsElemType = "iec-60309-3p-e-4h" +const ModuleTypePowerOutletsElemTypeIec603093PE6H ModuleTypePowerOutletsElemType = "iec-60309-3p-e-6h" +const ModuleTypePowerOutletsElemTypeIec603093PE9H ModuleTypePowerOutletsElemType = "iec-60309-3p-e-9h" +const ModuleTypePowerOutletsElemTypeIec603093PNE4H ModuleTypePowerOutletsElemType = "iec-60309-3p-n-e-4h" +const ModuleTypePowerOutletsElemTypeIec603093PNE6H ModuleTypePowerOutletsElemType = "iec-60309-3p-n-e-6h" +const ModuleTypePowerOutletsElemTypeIec603093PNE9H ModuleTypePowerOutletsElemType = "iec-60309-3p-n-e-9h" +const ModuleTypePowerOutletsElemTypeIec60309PNE4H ModuleTypePowerOutletsElemType = "iec-60309-p-n-e-4h" +const ModuleTypePowerOutletsElemTypeIec60309PNE6H ModuleTypePowerOutletsElemType = "iec-60309-p-n-e-6h" +const ModuleTypePowerOutletsElemTypeIec60309PNE9H ModuleTypePowerOutletsElemType = "iec-60309-p-n-e-9h" +const ModuleTypePowerOutletsElemTypeIec60320C13 ModuleTypePowerOutletsElemType = "iec-60320-c13" +const ModuleTypePowerOutletsElemTypeIec60320C15 ModuleTypePowerOutletsElemType = "iec-60320-c15" +const ModuleTypePowerOutletsElemTypeIec60320C19 ModuleTypePowerOutletsElemType = "iec-60320-c19" +const ModuleTypePowerOutletsElemTypeIec60320C21 ModuleTypePowerOutletsElemType = "iec-60320-c21" +const ModuleTypePowerOutletsElemTypeIec60320C5 ModuleTypePowerOutletsElemType = "iec-60320-c5" +const ModuleTypePowerOutletsElemTypeIec60320C7 ModuleTypePowerOutletsElemType = "iec-60320-c7" +const ModuleTypePowerOutletsElemTypeIec609061 ModuleTypePowerOutletsElemType = "iec-60906-1" +const ModuleTypePowerOutletsElemTypeItaE ModuleTypePowerOutletsElemType = "ita-e" +const ModuleTypePowerOutletsElemTypeItaF ModuleTypePowerOutletsElemType = "ita-f" +const ModuleTypePowerOutletsElemTypeItaG ModuleTypePowerOutletsElemType = "ita-g" +const ModuleTypePowerOutletsElemTypeItaH ModuleTypePowerOutletsElemType = "ita-h" +const ModuleTypePowerOutletsElemTypeItaI ModuleTypePowerOutletsElemType = "ita-i" +const ModuleTypePowerOutletsElemTypeItaJ ModuleTypePowerOutletsElemType = "ita-j" +const ModuleTypePowerOutletsElemTypeItaK ModuleTypePowerOutletsElemType = "ita-k" +const ModuleTypePowerOutletsElemTypeItaL ModuleTypePowerOutletsElemType = "ita-l" +const ModuleTypePowerOutletsElemTypeItaM ModuleTypePowerOutletsElemType = "ita-m" +const ModuleTypePowerOutletsElemTypeItaMultistandard ModuleTypePowerOutletsElemType = "ita-multistandard" +const ModuleTypePowerOutletsElemTypeItaN ModuleTypePowerOutletsElemType = "ita-n" +const ModuleTypePowerOutletsElemTypeItaO ModuleTypePowerOutletsElemType = "ita-o" +const ModuleTypePowerOutletsElemTypeNbr1413610A ModuleTypePowerOutletsElemType = "nbr-14136-10a" +const ModuleTypePowerOutletsElemTypeNbr1413620A ModuleTypePowerOutletsElemType = "nbr-14136-20a" +const ModuleTypePowerOutletsElemTypeNema1030R ModuleTypePowerOutletsElemType = "nema-10-30r" +const ModuleTypePowerOutletsElemTypeNema1050R ModuleTypePowerOutletsElemType = "nema-10-50r" +const ModuleTypePowerOutletsElemTypeNema115R ModuleTypePowerOutletsElemType = "nema-1-15r" +const ModuleTypePowerOutletsElemTypeNema1420R ModuleTypePowerOutletsElemType = "nema-14-20r" +const ModuleTypePowerOutletsElemTypeNema1430R ModuleTypePowerOutletsElemType = "nema-14-30r" +const ModuleTypePowerOutletsElemTypeNema1450R ModuleTypePowerOutletsElemType = "nema-14-50r" +const ModuleTypePowerOutletsElemTypeNema1460R ModuleTypePowerOutletsElemType = "nema-14-60r" +const ModuleTypePowerOutletsElemTypeNema1515R ModuleTypePowerOutletsElemType = "nema-15-15r" +const ModuleTypePowerOutletsElemTypeNema1520R ModuleTypePowerOutletsElemType = "nema-15-20r" +const ModuleTypePowerOutletsElemTypeNema1530R ModuleTypePowerOutletsElemType = "nema-15-30r" +const ModuleTypePowerOutletsElemTypeNema1550R ModuleTypePowerOutletsElemType = "nema-15-50r" +const ModuleTypePowerOutletsElemTypeNema1560R ModuleTypePowerOutletsElemType = "nema-15-60r" +const ModuleTypePowerOutletsElemTypeNema515R ModuleTypePowerOutletsElemType = "nema-5-15r" +const ModuleTypePowerOutletsElemTypeNema520R ModuleTypePowerOutletsElemType = "nema-5-20r" +const ModuleTypePowerOutletsElemTypeNema530R ModuleTypePowerOutletsElemType = "nema-5-30r" +const ModuleTypePowerOutletsElemTypeNema550R ModuleTypePowerOutletsElemType = "nema-5-50r" +const ModuleTypePowerOutletsElemTypeNema615R ModuleTypePowerOutletsElemType = "nema-6-15r" +const ModuleTypePowerOutletsElemTypeNema620R ModuleTypePowerOutletsElemType = "nema-6-20r" +const ModuleTypePowerOutletsElemTypeNema630R ModuleTypePowerOutletsElemType = "nema-6-30r" +const ModuleTypePowerOutletsElemTypeNema650R ModuleTypePowerOutletsElemType = "nema-6-50r" +const ModuleTypePowerOutletsElemTypeNemaL1030R ModuleTypePowerOutletsElemType = "nema-l10-30r" +const ModuleTypePowerOutletsElemTypeNemaL115R ModuleTypePowerOutletsElemType = "nema-l1-15r" +const ModuleTypePowerOutletsElemTypeNemaL1420R ModuleTypePowerOutletsElemType = "nema-l14-20r" +const ModuleTypePowerOutletsElemTypeNemaL1430R ModuleTypePowerOutletsElemType = "nema-l14-30r" +const ModuleTypePowerOutletsElemTypeNemaL1450R ModuleTypePowerOutletsElemType = "nema-l14-50r" +const ModuleTypePowerOutletsElemTypeNemaL1460R ModuleTypePowerOutletsElemType = "nema-l14-60r" +const ModuleTypePowerOutletsElemTypeNemaL1520R ModuleTypePowerOutletsElemType = "nema-l15-20r" +const ModuleTypePowerOutletsElemTypeNemaL1530R ModuleTypePowerOutletsElemType = "nema-l15-30r" +const ModuleTypePowerOutletsElemTypeNemaL1550R ModuleTypePowerOutletsElemType = "nema-l15-50r" +const ModuleTypePowerOutletsElemTypeNemaL1560R ModuleTypePowerOutletsElemType = "nema-l15-60r" +const ModuleTypePowerOutletsElemTypeNemaL2120R ModuleTypePowerOutletsElemType = "nema-l21-20r" +const ModuleTypePowerOutletsElemTypeNemaL2130R ModuleTypePowerOutletsElemType = "nema-l21-30r" +const ModuleTypePowerOutletsElemTypeNemaL2230R ModuleTypePowerOutletsElemType = "nema-l22-30r" +const ModuleTypePowerOutletsElemTypeNemaL515R ModuleTypePowerOutletsElemType = "nema-l5-15r" +const ModuleTypePowerOutletsElemTypeNemaL520R ModuleTypePowerOutletsElemType = "nema-l5-20r" +const ModuleTypePowerOutletsElemTypeNemaL530R ModuleTypePowerOutletsElemType = "nema-l5-30r" +const ModuleTypePowerOutletsElemTypeNemaL550R ModuleTypePowerOutletsElemType = "nema-l5-50r" +const ModuleTypePowerOutletsElemTypeNemaL615R ModuleTypePowerOutletsElemType = "nema-l6-15r" +const ModuleTypePowerOutletsElemTypeNemaL620R ModuleTypePowerOutletsElemType = "nema-l6-20r" +const ModuleTypePowerOutletsElemTypeNemaL630R ModuleTypePowerOutletsElemType = "nema-l6-30r" +const ModuleTypePowerOutletsElemTypeNemaL650R ModuleTypePowerOutletsElemType = "nema-l6-50r" +const ModuleTypePowerOutletsElemTypeNeutrikPowercon20A ModuleTypePowerOutletsElemType = "neutrik-powercon-20a" +const ModuleTypePowerOutletsElemTypeNeutrikPowercon32A ModuleTypePowerOutletsElemType = "neutrik-powercon-32a" +const ModuleTypePowerOutletsElemTypeNeutrikPowerconTrue1 ModuleTypePowerOutletsElemType = "neutrik-powercon-true1" +const ModuleTypePowerOutletsElemTypeNeutrikPowerconTrue1Top ModuleTypePowerOutletsElemType = "neutrik-powercon-true1-top" +const ModuleTypePowerOutletsElemTypeOther ModuleTypePowerOutletsElemType = "other" +const ModuleTypePowerOutletsElemTypeSafDGrid ModuleTypePowerOutletsElemType = "saf-d-grid" +const ModuleTypePowerOutletsElemTypeUbiquitiSmartpower ModuleTypePowerOutletsElemType = "ubiquiti-smartpower" +const ModuleTypePowerOutletsElemTypeUsbA ModuleTypePowerOutletsElemType = "usb-a" +const ModuleTypePowerOutletsElemTypeUsbC ModuleTypePowerOutletsElemType = "usb-c" +const ModuleTypePowerOutletsElemTypeUsbMicroB ModuleTypePowerOutletsElemType = "usb-micro-b" + +type ModuleTypePowerPortsElem struct { + // AllocatedDraw corresponds to the JSON schema field "allocated_draw". + AllocatedDraw *int `json:"allocated_draw,omitempty" yaml:"allocated_draw,omitempty" mapstructure:"allocated_draw,omitempty"` + + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // MaximumDraw corresponds to the JSON schema field "maximum_draw". + MaximumDraw *int `json:"maximum_draw,omitempty" yaml:"maximum_draw,omitempty" mapstructure:"maximum_draw,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // Type corresponds to the JSON schema field "type". + Type ModuleTypePowerPortsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type ModuleTypePowerPortsElemType string + +const ModuleTypePowerPortsElemTypeCs6361C ModuleTypePowerPortsElemType = "cs6361c" +const ModuleTypePowerPortsElemTypeCs6365C ModuleTypePowerPortsElemType = "cs6365c" +const ModuleTypePowerPortsElemTypeCs8165C ModuleTypePowerPortsElemType = "cs8165c" +const ModuleTypePowerPortsElemTypeCs8265C ModuleTypePowerPortsElemType = "cs8265c" +const ModuleTypePowerPortsElemTypeCs8365C ModuleTypePowerPortsElemType = "cs8365c" +const ModuleTypePowerPortsElemTypeCs8465C ModuleTypePowerPortsElemType = "cs8465c" +const ModuleTypePowerPortsElemTypeDcTerminal ModuleTypePowerPortsElemType = "dc-terminal" +const ModuleTypePowerPortsElemTypeHardwired ModuleTypePowerPortsElemType = "hardwired" +const ModuleTypePowerPortsElemTypeIec603092PE4H ModuleTypePowerPortsElemType = "iec-60309-2p-e-4h" +const ModuleTypePowerPortsElemTypeIec603092PE6H ModuleTypePowerPortsElemType = "iec-60309-2p-e-6h" +const ModuleTypePowerPortsElemTypeIec603092PE9H ModuleTypePowerPortsElemType = "iec-60309-2p-e-9h" +const ModuleTypePowerPortsElemTypeIec603093PE4H ModuleTypePowerPortsElemType = "iec-60309-3p-e-4h" +const ModuleTypePowerPortsElemTypeIec603093PE6H ModuleTypePowerPortsElemType = "iec-60309-3p-e-6h" +const ModuleTypePowerPortsElemTypeIec603093PE9H ModuleTypePowerPortsElemType = "iec-60309-3p-e-9h" +const ModuleTypePowerPortsElemTypeIec603093PNE4H ModuleTypePowerPortsElemType = "iec-60309-3p-n-e-4h" +const ModuleTypePowerPortsElemTypeIec603093PNE6H ModuleTypePowerPortsElemType = "iec-60309-3p-n-e-6h" +const ModuleTypePowerPortsElemTypeIec603093PNE9H ModuleTypePowerPortsElemType = "iec-60309-3p-n-e-9h" +const ModuleTypePowerPortsElemTypeIec60309PNE4H ModuleTypePowerPortsElemType = "iec-60309-p-n-e-4h" +const ModuleTypePowerPortsElemTypeIec60309PNE6H ModuleTypePowerPortsElemType = "iec-60309-p-n-e-6h" +const ModuleTypePowerPortsElemTypeIec60309PNE9H ModuleTypePowerPortsElemType = "iec-60309-p-n-e-9h" +const ModuleTypePowerPortsElemTypeIec60320C14 ModuleTypePowerPortsElemType = "iec-60320-c14" +const ModuleTypePowerPortsElemTypeIec60320C16 ModuleTypePowerPortsElemType = "iec-60320-c16" +const ModuleTypePowerPortsElemTypeIec60320C20 ModuleTypePowerPortsElemType = "iec-60320-c20" +const ModuleTypePowerPortsElemTypeIec60320C22 ModuleTypePowerPortsElemType = "iec-60320-c22" +const ModuleTypePowerPortsElemTypeIec60320C6 ModuleTypePowerPortsElemType = "iec-60320-c6" +const ModuleTypePowerPortsElemTypeIec60320C8 ModuleTypePowerPortsElemType = "iec-60320-c8" +const ModuleTypePowerPortsElemTypeIec609061 ModuleTypePowerPortsElemType = "iec-60906-1" +const ModuleTypePowerPortsElemTypeItaC ModuleTypePowerPortsElemType = "ita-c" +const ModuleTypePowerPortsElemTypeItaE ModuleTypePowerPortsElemType = "ita-e" +const ModuleTypePowerPortsElemTypeItaEf ModuleTypePowerPortsElemType = "ita-ef" +const ModuleTypePowerPortsElemTypeItaF ModuleTypePowerPortsElemType = "ita-f" +const ModuleTypePowerPortsElemTypeItaG ModuleTypePowerPortsElemType = "ita-g" +const ModuleTypePowerPortsElemTypeItaH ModuleTypePowerPortsElemType = "ita-h" +const ModuleTypePowerPortsElemTypeItaI ModuleTypePowerPortsElemType = "ita-i" +const ModuleTypePowerPortsElemTypeItaJ ModuleTypePowerPortsElemType = "ita-j" +const ModuleTypePowerPortsElemTypeItaK ModuleTypePowerPortsElemType = "ita-k" +const ModuleTypePowerPortsElemTypeItaL ModuleTypePowerPortsElemType = "ita-l" +const ModuleTypePowerPortsElemTypeItaM ModuleTypePowerPortsElemType = "ita-m" +const ModuleTypePowerPortsElemTypeItaN ModuleTypePowerPortsElemType = "ita-n" +const ModuleTypePowerPortsElemTypeItaO ModuleTypePowerPortsElemType = "ita-o" +const ModuleTypePowerPortsElemTypeNbr1413610A ModuleTypePowerPortsElemType = "nbr-14136-10a" +const ModuleTypePowerPortsElemTypeNbr1413620A ModuleTypePowerPortsElemType = "nbr-14136-20a" +const ModuleTypePowerPortsElemTypeNema1030P ModuleTypePowerPortsElemType = "nema-10-30p" +const ModuleTypePowerPortsElemTypeNema1050P ModuleTypePowerPortsElemType = "nema-10-50p" +const ModuleTypePowerPortsElemTypeNema115P ModuleTypePowerPortsElemType = "nema-1-15p" +const ModuleTypePowerPortsElemTypeNema1420P ModuleTypePowerPortsElemType = "nema-14-20p" +const ModuleTypePowerPortsElemTypeNema1430P ModuleTypePowerPortsElemType = "nema-14-30p" +const ModuleTypePowerPortsElemTypeNema1450P ModuleTypePowerPortsElemType = "nema-14-50p" +const ModuleTypePowerPortsElemTypeNema1460P ModuleTypePowerPortsElemType = "nema-14-60p" +const ModuleTypePowerPortsElemTypeNema1515P ModuleTypePowerPortsElemType = "nema-15-15p" +const ModuleTypePowerPortsElemTypeNema1520P ModuleTypePowerPortsElemType = "nema-15-20p" +const ModuleTypePowerPortsElemTypeNema1530P ModuleTypePowerPortsElemType = "nema-15-30p" +const ModuleTypePowerPortsElemTypeNema1550P ModuleTypePowerPortsElemType = "nema-15-50p" +const ModuleTypePowerPortsElemTypeNema1560P ModuleTypePowerPortsElemType = "nema-15-60p" +const ModuleTypePowerPortsElemTypeNema515P ModuleTypePowerPortsElemType = "nema-5-15p" +const ModuleTypePowerPortsElemTypeNema520P ModuleTypePowerPortsElemType = "nema-5-20p" +const ModuleTypePowerPortsElemTypeNema530P ModuleTypePowerPortsElemType = "nema-5-30p" +const ModuleTypePowerPortsElemTypeNema550P ModuleTypePowerPortsElemType = "nema-5-50p" +const ModuleTypePowerPortsElemTypeNema615P ModuleTypePowerPortsElemType = "nema-6-15p" +const ModuleTypePowerPortsElemTypeNema620P ModuleTypePowerPortsElemType = "nema-6-20p" +const ModuleTypePowerPortsElemTypeNema630P ModuleTypePowerPortsElemType = "nema-6-30p" +const ModuleTypePowerPortsElemTypeNema650P ModuleTypePowerPortsElemType = "nema-6-50p" +const ModuleTypePowerPortsElemTypeNemaL1030P ModuleTypePowerPortsElemType = "nema-l10-30p" +const ModuleTypePowerPortsElemTypeNemaL115P ModuleTypePowerPortsElemType = "nema-l1-15p" +const ModuleTypePowerPortsElemTypeNemaL1420P ModuleTypePowerPortsElemType = "nema-l14-20p" +const ModuleTypePowerPortsElemTypeNemaL1430P ModuleTypePowerPortsElemType = "nema-l14-30p" +const ModuleTypePowerPortsElemTypeNemaL1450P ModuleTypePowerPortsElemType = "nema-l14-50p" +const ModuleTypePowerPortsElemTypeNemaL1460P ModuleTypePowerPortsElemType = "nema-l14-60p" +const ModuleTypePowerPortsElemTypeNemaL1520P ModuleTypePowerPortsElemType = "nema-l15-20p" +const ModuleTypePowerPortsElemTypeNemaL1530P ModuleTypePowerPortsElemType = "nema-l15-30p" +const ModuleTypePowerPortsElemTypeNemaL1550P ModuleTypePowerPortsElemType = "nema-l15-50p" +const ModuleTypePowerPortsElemTypeNemaL1560P ModuleTypePowerPortsElemType = "nema-l15-60p" +const ModuleTypePowerPortsElemTypeNemaL2120P ModuleTypePowerPortsElemType = "nema-l21-20p" +const ModuleTypePowerPortsElemTypeNemaL2130P ModuleTypePowerPortsElemType = "nema-l21-30p" +const ModuleTypePowerPortsElemTypeNemaL2230P ModuleTypePowerPortsElemType = "nema-l22-30p" +const ModuleTypePowerPortsElemTypeNemaL515P ModuleTypePowerPortsElemType = "nema-l5-15p" +const ModuleTypePowerPortsElemTypeNemaL520P ModuleTypePowerPortsElemType = "nema-l5-20p" +const ModuleTypePowerPortsElemTypeNemaL530P ModuleTypePowerPortsElemType = "nema-l5-30p" +const ModuleTypePowerPortsElemTypeNemaL550P ModuleTypePowerPortsElemType = "nema-l5-50p" +const ModuleTypePowerPortsElemTypeNemaL615P ModuleTypePowerPortsElemType = "nema-l6-15p" +const ModuleTypePowerPortsElemTypeNemaL620P ModuleTypePowerPortsElemType = "nema-l6-20p" +const ModuleTypePowerPortsElemTypeNemaL630P ModuleTypePowerPortsElemType = "nema-l6-30p" +const ModuleTypePowerPortsElemTypeNemaL650P ModuleTypePowerPortsElemType = "nema-l6-50p" +const ModuleTypePowerPortsElemTypeNeutrikPowercon20 ModuleTypePowerPortsElemType = "neutrik-powercon-20" +const ModuleTypePowerPortsElemTypeNeutrikPowercon32 ModuleTypePowerPortsElemType = "neutrik-powercon-32" +const ModuleTypePowerPortsElemTypeNeutrikPowerconTrue1 ModuleTypePowerPortsElemType = "neutrik-powercon-true1" +const ModuleTypePowerPortsElemTypeNeutrikPowerconTrue1Top ModuleTypePowerPortsElemType = "neutrik-powercon-true1-top" +const ModuleTypePowerPortsElemTypeOther ModuleTypePowerPortsElemType = "other" +const ModuleTypePowerPortsElemTypeSafDGrid ModuleTypePowerPortsElemType = "saf-d-grid" +const ModuleTypePowerPortsElemTypeUbiquitiSmartpower ModuleTypePowerPortsElemType = "ubiquiti-smartpower" +const ModuleTypePowerPortsElemTypeUsb3B ModuleTypePowerPortsElemType = "usb-3-b" +const ModuleTypePowerPortsElemTypeUsb3MicroB ModuleTypePowerPortsElemType = "usb-3-micro-b" +const ModuleTypePowerPortsElemTypeUsbA ModuleTypePowerPortsElemType = "usb-a" +const ModuleTypePowerPortsElemTypeUsbB ModuleTypePowerPortsElemType = "usb-b" +const ModuleTypePowerPortsElemTypeUsbC ModuleTypePowerPortsElemType = "usb-c" +const ModuleTypePowerPortsElemTypeUsbMicroA ModuleTypePowerPortsElemType = "usb-micro-a" +const ModuleTypePowerPortsElemTypeUsbMicroAb ModuleTypePowerPortsElemType = "usb-micro-ab" +const ModuleTypePowerPortsElemTypeUsbMicroB ModuleTypePowerPortsElemType = "usb-micro-b" +const ModuleTypePowerPortsElemTypeUsbMiniA ModuleTypePowerPortsElemType = "usb-mini-a" +const ModuleTypePowerPortsElemTypeUsbMiniB ModuleTypePowerPortsElemType = "usb-mini-b" + +type ModuleTypeRearPortsElem struct { + // Color corresponds to the JSON schema field "color". + Color *string `json:"color,omitempty" yaml:"color,omitempty" mapstructure:"color,omitempty"` + + // Label corresponds to the JSON schema field "label". + Label *string `json:"label,omitempty" yaml:"label,omitempty" mapstructure:"label,omitempty"` + + // Name corresponds to the JSON schema field "name". + Name string `json:"name" yaml:"name" mapstructure:"name"` + + // Poe corresponds to the JSON schema field "poe". + Poe *bool `json:"poe,omitempty" yaml:"poe,omitempty" mapstructure:"poe,omitempty"` + + // Positions corresponds to the JSON schema field "positions". + Positions *int `json:"positions,omitempty" yaml:"positions,omitempty" mapstructure:"positions,omitempty"` + + // Type corresponds to the JSON schema field "type". + Type ModuleTypeRearPortsElemType `json:"type" yaml:"type" mapstructure:"type"` +} + +type ModuleTypeRearPortsElemType string + +const ModuleTypeRearPortsElemTypeA110Punch ModuleTypeRearPortsElemType = "110-punch" +const ModuleTypeRearPortsElemTypeA4P2C ModuleTypeRearPortsElemType = "4p2c" +const ModuleTypeRearPortsElemTypeA4P4C ModuleTypeRearPortsElemType = "4p4c" +const ModuleTypeRearPortsElemTypeA6P2C ModuleTypeRearPortsElemType = "6p2c" +const ModuleTypeRearPortsElemTypeA6P4C ModuleTypeRearPortsElemType = "6p4c" +const ModuleTypeRearPortsElemTypeA6P6C ModuleTypeRearPortsElemType = "6p6c" +const ModuleTypeRearPortsElemTypeA8P2C ModuleTypeRearPortsElemType = "8p2c" +const ModuleTypeRearPortsElemTypeA8P4C ModuleTypeRearPortsElemType = "8p4c" +const ModuleTypeRearPortsElemTypeA8P6C ModuleTypeRearPortsElemType = "8p6c" +const ModuleTypeRearPortsElemTypeA8P8C ModuleTypeRearPortsElemType = "8p8c" +const ModuleTypeRearPortsElemTypeBnc ModuleTypeRearPortsElemType = "bnc" +const ModuleTypeRearPortsElemTypeCs ModuleTypeRearPortsElemType = "cs" +const ModuleTypeRearPortsElemTypeF ModuleTypeRearPortsElemType = "f" +const ModuleTypeRearPortsElemTypeFc ModuleTypeRearPortsElemType = "fc" +const ModuleTypeRearPortsElemTypeGg45 ModuleTypeRearPortsElemType = "gg45" +const ModuleTypeRearPortsElemTypeLc ModuleTypeRearPortsElemType = "lc" +const ModuleTypeRearPortsElemTypeLcApc ModuleTypeRearPortsElemType = "lc-apc" +const ModuleTypeRearPortsElemTypeLcPc ModuleTypeRearPortsElemType = "lc-pc" +const ModuleTypeRearPortsElemTypeLcUpc ModuleTypeRearPortsElemType = "lc-upc" +const ModuleTypeRearPortsElemTypeLsh ModuleTypeRearPortsElemType = "lsh" +const ModuleTypeRearPortsElemTypeLshApc ModuleTypeRearPortsElemType = "lsh-apc" +const ModuleTypeRearPortsElemTypeLshPc ModuleTypeRearPortsElemType = "lsh-pc" +const ModuleTypeRearPortsElemTypeLshUpc ModuleTypeRearPortsElemType = "lsh-upc" +const ModuleTypeRearPortsElemTypeLx5 ModuleTypeRearPortsElemType = "lx5" +const ModuleTypeRearPortsElemTypeLx5Apc ModuleTypeRearPortsElemType = "lx5-apc" +const ModuleTypeRearPortsElemTypeLx5Pc ModuleTypeRearPortsElemType = "lx5-pc" +const ModuleTypeRearPortsElemTypeLx5Upc ModuleTypeRearPortsElemType = "lx5-upc" +const ModuleTypeRearPortsElemTypeMpo ModuleTypeRearPortsElemType = "mpo" +const ModuleTypeRearPortsElemTypeMrj21 ModuleTypeRearPortsElemType = "mrj21" +const ModuleTypeRearPortsElemTypeMtrj ModuleTypeRearPortsElemType = "mtrj" +const ModuleTypeRearPortsElemTypeN ModuleTypeRearPortsElemType = "n" +const ModuleTypeRearPortsElemTypeOther ModuleTypeRearPortsElemType = "other" +const ModuleTypeRearPortsElemTypeSc ModuleTypeRearPortsElemType = "sc" +const ModuleTypeRearPortsElemTypeScApc ModuleTypeRearPortsElemType = "sc-apc" +const ModuleTypeRearPortsElemTypeScPc ModuleTypeRearPortsElemType = "sc-pc" +const ModuleTypeRearPortsElemTypeScUpc ModuleTypeRearPortsElemType = "sc-upc" +const ModuleTypeRearPortsElemTypeSma905 ModuleTypeRearPortsElemType = "sma-905" +const ModuleTypeRearPortsElemTypeSma906 ModuleTypeRearPortsElemType = "sma-906" +const ModuleTypeRearPortsElemTypeSn ModuleTypeRearPortsElemType = "sn" +const ModuleTypeRearPortsElemTypeSplice ModuleTypeRearPortsElemType = "splice" +const ModuleTypeRearPortsElemTypeSt ModuleTypeRearPortsElemType = "st" +const ModuleTypeRearPortsElemTypeTera1P ModuleTypeRearPortsElemType = "tera-1p" +const ModuleTypeRearPortsElemTypeTera2P ModuleTypeRearPortsElemType = "tera-2p" +const ModuleTypeRearPortsElemTypeTera4P ModuleTypeRearPortsElemType = "tera-4p" +const ModuleTypeRearPortsElemTypeUrmP2 ModuleTypeRearPortsElemType = "urm-p2" +const ModuleTypeRearPortsElemTypeUrmP4 ModuleTypeRearPortsElemType = "urm-p4" + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeInterfacesElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypeInterfacesElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypeInterfacesElemType, v) + } + *j = ModuleTypeInterfacesElemType(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeConsolePortsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypeConsolePortsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypeConsolePortsElemType, v) + } + *j = ModuleTypeConsolePortsElemType(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypePowerOutletsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in ModuleTypePowerOutletsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in ModuleTypePowerOutletsElem: required") + } + type Plain ModuleTypePowerOutletsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = ModuleTypePowerOutletsElem(plain) + return nil +} + +var enumValues_ModuleTypeConsoleServerPortsElemType = []interface{}{ + "de-9", + "db-25", + "rj-11", + "rj-12", + "rj-45", + "mini-din-8", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "other", +} +var enumValues_ModuleTypePowerPortsElemType = []interface{}{ + "iec-60320-c6", + "iec-60320-c8", + "iec-60320-c14", + "iec-60320-c16", + "iec-60320-c20", + "iec-60320-c22", + "iec-60309-p-n-e-4h", + "iec-60309-p-n-e-6h", + "iec-60309-p-n-e-9h", + "iec-60309-2p-e-4h", + "iec-60309-2p-e-6h", + "iec-60309-2p-e-9h", + "iec-60309-3p-e-4h", + "iec-60309-3p-e-6h", + "iec-60309-3p-e-9h", + "iec-60309-3p-n-e-4h", + "iec-60309-3p-n-e-6h", + "iec-60309-3p-n-e-9h", + "iec-60906-1", + "nbr-14136-10a", + "nbr-14136-20a", + "nema-1-15p", + "nema-5-15p", + "nema-5-20p", + "nema-5-30p", + "nema-5-50p", + "nema-6-15p", + "nema-6-20p", + "nema-6-30p", + "nema-6-50p", + "nema-10-30p", + "nema-10-50p", + "nema-14-20p", + "nema-14-30p", + "nema-14-50p", + "nema-14-60p", + "nema-15-15p", + "nema-15-20p", + "nema-15-30p", + "nema-15-50p", + "nema-15-60p", + "nema-l1-15p", + "nema-l5-15p", + "nema-l5-20p", + "nema-l5-30p", + "nema-l5-50p", + "nema-l6-15p", + "nema-l6-20p", + "nema-l6-30p", + "nema-l6-50p", + "nema-l10-30p", + "nema-l14-20p", + "nema-l14-30p", + "nema-l14-50p", + "nema-l14-60p", + "nema-l15-20p", + "nema-l15-30p", + "nema-l15-50p", + "nema-l15-60p", + "nema-l21-20p", + "nema-l21-30p", + "nema-l22-30p", + "cs6361c", + "cs6365c", + "cs8165c", + "cs8265c", + "cs8365c", + "cs8465c", + "ita-c", + "ita-e", + "ita-f", + "ita-ef", + "ita-g", + "ita-h", + "ita-i", + "ita-j", + "ita-k", + "ita-l", + "ita-m", + "ita-n", + "ita-o", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "usb-3-b", + "usb-3-micro-b", + "dc-terminal", + "saf-d-grid", + "neutrik-powercon-20", + "neutrik-powercon-32", + "neutrik-powercon-true1", + "neutrik-powercon-true1-top", + "ubiquiti-smartpower", + "hardwired", + "other", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeConsoleServerPortsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypeConsoleServerPortsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypeConsoleServerPortsElemType, v) + } + *j = ModuleTypeConsoleServerPortsElemType(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeConsoleServerPortsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in ModuleTypeConsoleServerPortsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in ModuleTypeConsoleServerPortsElem: required") + } + type Plain ModuleTypeConsoleServerPortsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = ModuleTypeConsoleServerPortsElem(plain) + return nil +} + +var enumValues_ModuleTypeFrontPortsElemType = []interface{}{ + "8p8c", + "8p6c", + "8p4c", + "8p2c", + "6p6c", + "6p4c", + "6p2c", + "4p4c", + "4p2c", + "gg45", + "tera-4p", + "tera-2p", + "tera-1p", + "110-punch", + "bnc", + "f", + "n", + "mrj21", + "fc", + "lc", + "lc-pc", + "lc-upc", + "lc-apc", + "lsh", + "lsh-pc", + "lsh-upc", + "lsh-apc", + "lx5", + "lx5-pc", + "lx5-upc", + "lx5-apc", + "mpo", + "mtrj", + "sc", + "sc-pc", + "sc-upc", + "sc-apc", + "st", + "cs", + "sn", + "sma-905", + "sma-906", + "urm-p2", + "urm-p4", + "urm-p8", + "splice", + "other", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeFrontPortsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypeFrontPortsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypeFrontPortsElemType, v) + } + *j = ModuleTypeFrontPortsElemType(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeFrontPortsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in ModuleTypeFrontPortsElem: required") + } + if v, ok := raw["rear_port"]; !ok || v == nil { + return fmt.Errorf("field rear_port in ModuleTypeFrontPortsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in ModuleTypeFrontPortsElem: required") + } + type Plain ModuleTypeFrontPortsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = ModuleTypeFrontPortsElem(plain) + return nil +} + +var enumValues_ModuleTypeInterfacesElemPoeMode = []interface{}{ + "pd", + "pse", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeInterfacesElemPoeMode) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypeInterfacesElemPoeMode { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypeInterfacesElemPoeMode, v) + } + *j = ModuleTypeInterfacesElemPoeMode(v) + return nil +} + +var enumValues_ModuleTypeInterfacesElemPoeType = []interface{}{ + "type1-ieee802.3af", + "type2-ieee802.3at", + "type3-ieee802.3bt", + "type4-ieee802.3bt", + "passive-24v-2pair", + "passive-24v-4pair", + "passive-48v-2pair", + "passive-48v-4pair", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeInterfacesElemPoeType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypeInterfacesElemPoeType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypeInterfacesElemPoeType, v) + } + *j = ModuleTypeInterfacesElemPoeType(v) + return nil +} + +var enumValues_ModuleTypeInterfacesElemType = []interface{}{ + "virtual", + "bridge", + "lag", + "100base-fx", + "100base-lfx", + "100base-tx", + "100base-t1", + "1000base-t", + "2.5gbase-t", + "5gbase-t", + "10gbase-t", + "10gbase-cx4", + "1000base-x-gbic", + "1000base-x-sfp", + "10gbase-x-sfpp", + "10gbase-x-xfp", + "10gbase-x-xenpak", + "10gbase-x-x2", + "25gbase-x-sfp28", + "50gbase-x-sfp56", + "40gbase-x-qsfpp", + "50gbase-x-sfp28", + "100gbase-x-cfp", + "100gbase-x-cfp2", + "200gbase-x-cfp2", + "400gbase-x-cfp2", + "100gbase-x-cfp4", + "100gbase-x-cxp", + "100gbase-x-cpak", + "100gbase-x-dsfp", + "100gbase-x-sfpdd", + "100gbase-x-qsfp28", + "100gbase-x-qsfpdd", + "200gbase-x-qsfp56", + "200gbase-x-qsfpdd", + "400gbase-x-qsfp112", + "400gbase-x-qsfpdd", + "400gbase-x-osfp", + "400gbase-x-osfp-rhs", + "400gbase-x-cdfp", + "400gbase-x-cfp8", + "800gbase-x-qsfpdd", + "800gbase-x-osfp", + "1000base-kx", + "10gbase-kr", + "10gbase-kx4", + "25gbase-kr", + "40gbase-kr4", + "50gbase-kr", + "100gbase-kp4", + "100gbase-kr2", + "100gbase-kr4", + "ieee802.11a", + "ieee802.11g", + "ieee802.11n", + "ieee802.11ac", + "ieee802.11ad", + "ieee802.11ax", + "ieee802.11ay", + "ieee802.15.1", + "other-wireless", + "gsm", + "cdma", + "lte", + "sonet-oc3", + "sonet-oc12", + "sonet-oc48", + "sonet-oc192", + "sonet-oc768", + "sonet-oc1920", + "sonet-oc3840", + "1gfc-sfp", + "2gfc-sfp", + "4gfc-sfp", + "8gfc-sfpp", + "16gfc-sfpp", + "32gfc-sfp28", + "64gfc-qsfpp", + "128gfc-qsfp28", + "infiniband-sdr", + "infiniband-ddr", + "infiniband-qdr", + "infiniband-fdr10", + "infiniband-fdr", + "infiniband-edr", + "infiniband-hdr", + "infiniband-ndr", + "infiniband-xdr", + "t1", + "e1", + "t3", + "e3", + "xdsl", + "docsis", + "gpon", + "xg-pon", + "xgs-pon", + "ng-pon2", + "epon", + "10g-epon", + "cisco-stackwise", + "cisco-stackwise-plus", + "cisco-flexstack", + "cisco-flexstack-plus", + "cisco-stackwise-80", + "cisco-stackwise-160", + "cisco-stackwise-320", + "cisco-stackwise-480", + "cisco-stackwise-1t", + "juniper-vcp", + "extreme-summitstack", + "extreme-summitstack-128", + "extreme-summitstack-256", + "extreme-summitstack-512", + "other", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypePowerOutletsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypePowerOutletsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypePowerOutletsElemType, v) + } + *j = ModuleTypePowerOutletsElemType(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypePowerPortsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypePowerPortsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypePowerPortsElemType, v) + } + *j = ModuleTypePowerPortsElemType(v) + return nil +} + +var enumValues_ModuleTypePowerOutletsElemType = []interface{}{ + "iec-60320-c5", + "iec-60320-c7", + "iec-60320-c13", + "iec-60320-c15", + "iec-60320-c19", + "iec-60320-c21", + "iec-60309-p-n-e-4h", + "iec-60309-p-n-e-6h", + "iec-60309-p-n-e-9h", + "iec-60309-2p-e-4h", + "iec-60309-2p-e-6h", + "iec-60309-2p-e-9h", + "iec-60309-3p-e-4h", + "iec-60309-3p-e-6h", + "iec-60309-3p-e-9h", + "iec-60309-3p-n-e-4h", + "iec-60309-3p-n-e-6h", + "iec-60309-3p-n-e-9h", + "iec-60906-1", + "nbr-14136-10a", + "nbr-14136-20a", + "nema-1-15r", + "nema-5-15r", + "nema-5-20r", + "nema-5-30r", + "nema-5-50r", + "nema-6-15r", + "nema-6-20r", + "nema-6-30r", + "nema-6-50r", + "nema-10-30r", + "nema-10-50r", + "nema-14-20r", + "nema-14-30r", + "nema-14-50r", + "nema-14-60r", + "nema-15-15r", + "nema-15-20r", + "nema-15-30r", + "nema-15-50r", + "nema-15-60r", + "nema-l1-15r", + "nema-l5-15r", + "nema-l5-20r", + "nema-l5-30r", + "nema-l5-50r", + "nema-l6-15r", + "nema-l6-20r", + "nema-l6-30r", + "nema-l6-50r", + "nema-l10-30r", + "nema-l14-20r", + "nema-l14-30r", + "nema-l14-50r", + "nema-l14-60r", + "nema-l15-20r", + "nema-l15-30r", + "nema-l15-50r", + "nema-l15-60r", + "nema-l21-20r", + "nema-l21-30r", + "nema-l22-30r", + "CS6360C", + "CS6364C", + "CS8164C", + "CS8264C", + "CS8364C", + "CS8464C", + "ita-e", + "ita-f", + "ita-g", + "ita-h", + "ita-i", + "ita-j", + "ita-k", + "ita-l", + "ita-m", + "ita-n", + "ita-o", + "ita-multistandard", + "usb-a", + "usb-micro-b", + "usb-c", + "dc-terminal", + "hdot-cx", + "saf-d-grid", + "neutrik-powercon-20a", + "neutrik-powercon-32a", + "neutrik-powercon-true1", + "neutrik-powercon-true1-top", + "ubiquiti-smartpower", + "hardwired", + "other", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeConsolePortsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in ModuleTypeConsolePortsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in ModuleTypeConsolePortsElem: required") + } + type Plain ModuleTypeConsolePortsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = ModuleTypeConsolePortsElem(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeInterfacesElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in ModuleTypeInterfacesElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in ModuleTypeInterfacesElem: required") + } + type Plain ModuleTypeInterfacesElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = ModuleTypeInterfacesElem(plain) + return nil +} + +var enumValues_ModuleTypePowerOutletsElemFeedLeg = []interface{}{ + "A", + "B", + "C", +} +var enumValues_ModuleTypeRearPortsElemType = []interface{}{ + "8p8c", + "8p6c", + "8p4c", + "8p2c", + "6p6c", + "6p4c", + "6p2c", + "4p4c", + "4p2c", + "gg45", + "tera-4p", + "tera-2p", + "tera-1p", + "110-punch", + "bnc", + "f", + "n", + "mrj21", + "fc", + "lc", + "lc-pc", + "lc-upc", + "lc-apc", + "lsh", + "lsh-pc", + "lsh-upc", + "lsh-apc", + "lx5", + "lx5-pc", + "lx5-upc", + "lx5-apc", + "mpo", + "mtrj", + "sc", + "sc-pc", + "sc-upc", + "sc-apc", + "st", + "cs", + "sn", + "sma-905", + "sma-906", + "urm-p2", + "urm-p4", + "urm-p8", + "splice", + "other", +} + +const ModuleTypeRearPortsElemTypeUrmP8 ModuleTypeRearPortsElemType = "urm-p8" + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypePowerPortsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in ModuleTypePowerPortsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in ModuleTypePowerPortsElem: required") + } + type Plain ModuleTypePowerPortsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = ModuleTypePowerPortsElem(plain) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeRearPortsElemType) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypeRearPortsElemType { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypeRearPortsElemType, v) + } + *j = ModuleTypeRearPortsElemType(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypePowerOutletsElemFeedLeg) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypePowerOutletsElemFeedLeg { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypePowerOutletsElemFeedLeg, v) + } + *j = ModuleTypePowerOutletsElemFeedLeg(v) + return nil +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeRearPortsElem) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["name"]; !ok || v == nil { + return fmt.Errorf("field name in ModuleTypeRearPortsElem: required") + } + if v, ok := raw["type"]; !ok || v == nil { + return fmt.Errorf("field type in ModuleTypeRearPortsElem: required") + } + type Plain ModuleTypeRearPortsElem + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = ModuleTypeRearPortsElem(plain) + return nil +} + +type ModuleTypeWeightUnit string + +var enumValues_ModuleTypeWeightUnit = []interface{}{ + "kg", + "g", + "lb", + "oz", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleTypeWeightUnit) UnmarshalJSON(b []byte) error { + var v string + if err := json.Unmarshal(b, &v); err != nil { + return err + } + var ok bool + for _, expected := range enumValues_ModuleTypeWeightUnit { + if reflect.DeepEqual(v, expected) { + ok = true + break + } + } + if !ok { + return fmt.Errorf("invalid value (expected one of %#v): %#v", enumValues_ModuleTypeWeightUnit, v) + } + *j = ModuleTypeWeightUnit(v) + return nil +} + +const ModuleTypeWeightUnitKg ModuleTypeWeightUnit = "kg" +const ModuleTypeWeightUnitG ModuleTypeWeightUnit = "g" +const ModuleTypeWeightUnitLb ModuleTypeWeightUnit = "lb" +const ModuleTypeWeightUnitOz ModuleTypeWeightUnit = "oz" + +var enumValues_ModuleTypeConsolePortsElemType = []interface{}{ + "de-9", + "db-25", + "rj-11", + "rj-12", + "rj-45", + "mini-din-8", + "usb-a", + "usb-b", + "usb-c", + "usb-mini-a", + "usb-mini-b", + "usb-micro-a", + "usb-micro-b", + "usb-micro-ab", + "other", +} + +// UnmarshalJSON implements json.Unmarshaler. +func (j *ModuleType) UnmarshalJSON(b []byte) error { + var raw map[string]interface{} + if err := json.Unmarshal(b, &raw); err != nil { + return err + } + if v, ok := raw["manufacturer"]; !ok || v == nil { + return fmt.Errorf("field manufacturer in ModuleType: required") + } + if v, ok := raw["model"]; !ok || v == nil { + return fmt.Errorf("field model in ModuleType: required") + } + type Plain ModuleType + var plain Plain + if err := json.Unmarshal(b, &plain); err != nil { + return err + } + *j = ModuleType(plain) + return nil +} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_compare.go b/vendor/github.com/stretchr/testify/assert/assertion_compare.go index 3bb22a97..b774da88 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_compare.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_compare.go @@ -1,6 +1,7 @@ package assert import ( + "bytes" "fmt" "reflect" "time" @@ -32,7 +33,8 @@ var ( stringType = reflect.TypeOf("") - timeType = reflect.TypeOf(time.Time{}) + timeType = reflect.TypeOf(time.Time{}) + bytesType = reflect.TypeOf([]byte{}) ) func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { @@ -323,6 +325,26 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { return compare(timeObj1.UnixNano(), timeObj2.UnixNano(), reflect.Int64) } + case reflect.Slice: + { + // We only care about the []byte type. + if !canConvert(obj1Value, bytesType) { + break + } + + // []byte can be compared! + bytesObj1, ok := obj1.([]byte) + if !ok { + bytesObj1 = obj1Value.Convert(bytesType).Interface().([]byte) + + } + bytesObj2, ok := obj2.([]byte) + if !ok { + bytesObj2 = obj2Value.Convert(bytesType).Interface().([]byte) + } + + return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true + } } return compareEqual, false @@ -330,9 +352,9 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { // Greater asserts that the first element is greater than the second // -// assert.Greater(t, 2, 1) -// assert.Greater(t, float64(2), float64(1)) -// assert.Greater(t, "b", "a") +// assert.Greater(t, 2, 1) +// assert.Greater(t, float64(2), float64(1)) +// assert.Greater(t, "b", "a") func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -342,10 +364,10 @@ func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface // GreaterOrEqual asserts that the first element is greater than or equal to the second // -// assert.GreaterOrEqual(t, 2, 1) -// assert.GreaterOrEqual(t, 2, 2) -// assert.GreaterOrEqual(t, "b", "a") -// assert.GreaterOrEqual(t, "b", "b") +// assert.GreaterOrEqual(t, 2, 1) +// assert.GreaterOrEqual(t, 2, 2) +// assert.GreaterOrEqual(t, "b", "a") +// assert.GreaterOrEqual(t, "b", "b") func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -355,9 +377,9 @@ func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...in // Less asserts that the first element is less than the second // -// assert.Less(t, 1, 2) -// assert.Less(t, float64(1), float64(2)) -// assert.Less(t, "a", "b") +// assert.Less(t, 1, 2) +// assert.Less(t, float64(1), float64(2)) +// assert.Less(t, "a", "b") func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -367,10 +389,10 @@ func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) // LessOrEqual asserts that the first element is less than or equal to the second // -// assert.LessOrEqual(t, 1, 2) -// assert.LessOrEqual(t, 2, 2) -// assert.LessOrEqual(t, "a", "b") -// assert.LessOrEqual(t, "b", "b") +// assert.LessOrEqual(t, 1, 2) +// assert.LessOrEqual(t, 2, 2) +// assert.LessOrEqual(t, "a", "b") +// assert.LessOrEqual(t, "b", "b") func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -380,8 +402,8 @@ func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inter // Positive asserts that the specified element is positive // -// assert.Positive(t, 1) -// assert.Positive(t, 1.23) +// assert.Positive(t, 1) +// assert.Positive(t, 1.23) func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -392,8 +414,8 @@ func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) bool { // Negative asserts that the specified element is negative // -// assert.Negative(t, -1) -// assert.Negative(t, -1.23) +// assert.Negative(t, -1) +// assert.Negative(t, -1.23) func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go b/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go index df22c47f..da867903 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go @@ -9,7 +9,7 @@ package assert import "reflect" -// Wrapper around reflect.Value.CanConvert, for compatability +// Wrapper around reflect.Value.CanConvert, for compatibility // reasons. func canConvert(value reflect.Value, to reflect.Type) bool { return value.CanConvert(to) diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go b/vendor/github.com/stretchr/testify/assert/assertion_format.go index 27e2420e..84dbd6c7 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_format.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_format.go @@ -22,9 +22,9 @@ func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bo // Containsf asserts that the specified string, list(array, slice...) or map contains the // specified substring or element. // -// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") -// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") -// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") +// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") +// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") +// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -56,7 +56,7 @@ func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string // Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either // a slice or a channel with len == 0. // -// assert.Emptyf(t, obj, "error message %s", "formatted") +// assert.Emptyf(t, obj, "error message %s", "formatted") func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -66,7 +66,7 @@ func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) boo // Equalf asserts that two objects are equal. // -// assert.Equalf(t, 123, 123, "error message %s", "formatted") +// assert.Equalf(t, 123, 123, "error message %s", "formatted") // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). Function equality @@ -81,8 +81,8 @@ func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, ar // EqualErrorf asserts that a function returned an error (i.e. not `nil`) // and that it is equal to the provided error. // -// actualObj, err := SomeFunction() -// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") +// actualObj, err := SomeFunction() +// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -90,10 +90,27 @@ func EqualErrorf(t TestingT, theError error, errString string, msg string, args return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...) } +// EqualExportedValuesf asserts that the types of two objects are equal and their public +// fields are also equal. This is useful for comparing structs that have private fields +// that could potentially differ. +// +// type S struct { +// Exported int +// notExported int +// } +// assert.EqualExportedValuesf(t, S{1, 2}, S{1, 3}, "error message %s", "formatted") => true +// assert.EqualExportedValuesf(t, S{1, 2}, S{2, 3}, "error message %s", "formatted") => false +func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...) +} + // EqualValuesf asserts that two objects are equal or convertable to the same types // and equal. // -// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted") +// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted") func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -103,10 +120,10 @@ func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg stri // Errorf asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if assert.Errorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } +// actualObj, err := SomeFunction() +// if assert.Errorf(t, err, "error message %s", "formatted") { +// assert.Equal(t, expectedErrorf, err) +// } func Errorf(t TestingT, err error, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -126,8 +143,8 @@ func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...int // ErrorContainsf asserts that a function returned an error (i.e. not `nil`) // and that the error contains the specified substring. // -// actualObj, err := SomeFunction() -// assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted") +// actualObj, err := SomeFunction() +// assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted") func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -147,7 +164,7 @@ func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface // Eventuallyf asserts that given condition will be met in waitFor time, // periodically checking target function each tick. // -// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") +// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -155,9 +172,34 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick return Eventually(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...) } +// EventuallyWithTf asserts that given condition will be met in waitFor time, +// periodically checking target function each tick. In contrast to Eventually, +// it supplies a CollectT to the condition function, so that the condition +// function can use the CollectT to call other assertions. +// The condition is considered "met" if no errors are raised in a tick. +// The supplied CollectT collects all errors from one tick (if there are any). +// If the condition is not met before waitFor, the collected errors of +// the last tick are copied to t. +// +// externalValue := false +// go func() { +// time.Sleep(8*time.Second) +// externalValue = true +// }() +// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") { +// // add assertions as needed; any assertion failure will fail the current tick +// assert.True(c, externalValue, "expected 'externalValue' to be true") +// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +func EventuallyWithTf(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return EventuallyWithT(t, condition, waitFor, tick, append([]interface{}{msg}, args...)...) +} + // Exactlyf asserts that two objects are equal in value and type. // -// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted") +// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted") func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -183,7 +225,7 @@ func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{} // Falsef asserts that the specified value is false. // -// assert.Falsef(t, myBool, "error message %s", "formatted") +// assert.Falsef(t, myBool, "error message %s", "formatted") func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -202,9 +244,9 @@ func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool // Greaterf asserts that the first element is greater than the second // -// assert.Greaterf(t, 2, 1, "error message %s", "formatted") -// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted") -// assert.Greaterf(t, "b", "a", "error message %s", "formatted") +// assert.Greaterf(t, 2, 1, "error message %s", "formatted") +// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted") +// assert.Greaterf(t, "b", "a", "error message %s", "formatted") func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -214,10 +256,10 @@ func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...in // GreaterOrEqualf asserts that the first element is greater than or equal to the second // -// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted") -// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted") -// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted") -// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted") +// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted") +// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted") +// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted") +// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted") func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -228,7 +270,7 @@ func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, arg // HTTPBodyContainsf asserts that a specified handler returns a // body that contains a string. // -// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { @@ -241,7 +283,7 @@ func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url // HTTPBodyNotContainsf asserts that a specified handler returns a // body that does not contain a string. // -// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { @@ -253,7 +295,7 @@ func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, u // HTTPErrorf asserts that a specified handler returns an error status code. // -// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { @@ -265,7 +307,7 @@ func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, // HTTPRedirectf asserts that a specified handler returns a redirect status code. // -// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { @@ -277,7 +319,7 @@ func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url stri // HTTPStatusCodef asserts that a specified handler returns a specified status code. // -// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") +// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool { @@ -289,7 +331,7 @@ func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url st // HTTPSuccessf asserts that a specified handler returns a success status code. // -// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") +// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { @@ -301,7 +343,7 @@ func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url strin // Implementsf asserts that an object is implemented by the specified interface. // -// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted") +// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted") func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -311,7 +353,7 @@ func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, ms // InDeltaf asserts that the two numerals are within delta of each other. // -// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted") +// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted") func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -353,9 +395,9 @@ func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsil // IsDecreasingf asserts that the collection is decreasing // -// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted") -// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted") -// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted") +// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted") +// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted") +// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted") func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -365,9 +407,9 @@ func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface // IsIncreasingf asserts that the collection is increasing // -// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted") -// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted") -// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted") +// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted") +// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted") +// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted") func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -377,9 +419,9 @@ func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface // IsNonDecreasingf asserts that the collection is not decreasing // -// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted") -// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted") -// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted") +// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted") +// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted") +// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted") func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -389,9 +431,9 @@ func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interf // IsNonIncreasingf asserts that the collection is not increasing // -// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted") -// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted") -// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted") +// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted") +// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted") +// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted") func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -409,7 +451,7 @@ func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg strin // JSONEqf asserts that two JSON strings are equivalent. // -// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") +// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -420,7 +462,7 @@ func JSONEqf(t TestingT, expected string, actual string, msg string, args ...int // Lenf asserts that the specified object has specific length. // Lenf also fails if the object has a type that len() not accept. // -// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") +// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -430,9 +472,9 @@ func Lenf(t TestingT, object interface{}, length int, msg string, args ...interf // Lessf asserts that the first element is less than the second // -// assert.Lessf(t, 1, 2, "error message %s", "formatted") -// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted") -// assert.Lessf(t, "a", "b", "error message %s", "formatted") +// assert.Lessf(t, 1, 2, "error message %s", "formatted") +// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted") +// assert.Lessf(t, "a", "b", "error message %s", "formatted") func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -442,10 +484,10 @@ func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...inter // LessOrEqualf asserts that the first element is less than or equal to the second // -// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted") -// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted") -// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted") -// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted") +// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted") +// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted") +// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted") +// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted") func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -455,8 +497,8 @@ func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args . // Negativef asserts that the specified element is negative // -// assert.Negativef(t, -1, "error message %s", "formatted") -// assert.Negativef(t, -1.23, "error message %s", "formatted") +// assert.Negativef(t, -1, "error message %s", "formatted") +// assert.Negativef(t, -1.23, "error message %s", "formatted") func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -467,7 +509,7 @@ func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) bool // Neverf asserts that the given condition doesn't satisfy in waitFor time, // periodically checking the target function each tick. // -// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") +// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -477,7 +519,7 @@ func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time. // Nilf asserts that the specified object is nil. // -// assert.Nilf(t, err, "error message %s", "formatted") +// assert.Nilf(t, err, "error message %s", "formatted") func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -496,10 +538,10 @@ func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) bool // NoErrorf asserts that a function returned no error (i.e. `nil`). // -// actualObj, err := SomeFunction() -// if assert.NoErrorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// if assert.NoErrorf(t, err, "error message %s", "formatted") { +// assert.Equal(t, expectedObj, actualObj) +// } func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -519,9 +561,9 @@ func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) boo // NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // -// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") -// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") -// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") +// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") +// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") +// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -532,9 +574,9 @@ func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, a // NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // -// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } +// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { +// assert.Equal(t, "two", obj[1]) +// } func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -544,7 +586,7 @@ func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) // NotEqualf asserts that the specified values are NOT equal. // -// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") +// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). @@ -557,7 +599,7 @@ func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, // NotEqualValuesf asserts that two objects are not equal even when converted to the same type // -// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted") +// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted") func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -576,7 +618,7 @@ func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interf // NotNilf asserts that the specified object is not nil. // -// assert.NotNilf(t, err, "error message %s", "formatted") +// assert.NotNilf(t, err, "error message %s", "formatted") func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -586,7 +628,7 @@ func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bo // NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. // -// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") +// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -596,8 +638,8 @@ func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bo // NotRegexpf asserts that a specified regexp does not match a string. // -// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") -// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") +// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") +// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -607,7 +649,7 @@ func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args .. // NotSamef asserts that two pointers do not reference the same object. // -// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted") +// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted") // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -621,7 +663,7 @@ func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, // NotSubsetf asserts that the specified list(array, slice...) contains not all // elements given in the specified subset(array, slice...). // -// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -639,7 +681,7 @@ func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool { // Panicsf asserts that the code inside the specified PanicTestFunc panics. // -// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") +// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -651,7 +693,7 @@ func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool // panics, and that the recovered panic value is an error that satisfies the // EqualError comparison. // -// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -662,7 +704,7 @@ func PanicsWithErrorf(t TestingT, errString string, f PanicTestFunc, msg string, // PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that // the recovered panic value equals the expected panic value. // -// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -672,8 +714,8 @@ func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg str // Positivef asserts that the specified element is positive // -// assert.Positivef(t, 1, "error message %s", "formatted") -// assert.Positivef(t, 1.23, "error message %s", "formatted") +// assert.Positivef(t, 1, "error message %s", "formatted") +// assert.Positivef(t, 1.23, "error message %s", "formatted") func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -683,8 +725,8 @@ func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) bool // Regexpf asserts that a specified regexp matches a string. // -// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") -// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") +// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") +// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -694,7 +736,7 @@ func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...in // Samef asserts that two pointers reference the same object. // -// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted") +// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted") // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -708,7 +750,7 @@ func Samef(t TestingT, expected interface{}, actual interface{}, msg string, arg // Subsetf asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // -// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -718,7 +760,7 @@ func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args // Truef asserts that the specified value is true. // -// assert.Truef(t, myBool, "error message %s", "formatted") +// assert.Truef(t, myBool, "error message %s", "formatted") func Truef(t TestingT, value bool, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -728,7 +770,7 @@ func Truef(t TestingT, value bool, msg string, args ...interface{}) bool { // WithinDurationf asserts that the two times are within duration delta of each other. // -// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") +// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -736,6 +778,16 @@ func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta tim return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...) } +// WithinRangef asserts that a time is within a time range (inclusive). +// +// assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted") +func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return WithinRange(t, actual, start, end, append([]interface{}{msg}, args...)...) +} + // YAMLEqf asserts that two YAML strings are equivalent. func YAMLEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/vendor/github.com/stretchr/testify/assert/assertion_forward.go index d9ea368d..b1d94aec 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_forward.go @@ -30,9 +30,9 @@ func (a *Assertions) Conditionf(comp Comparison, msg string, args ...interface{} // Contains asserts that the specified string, list(array, slice...) or map contains the // specified substring or element. // -// a.Contains("Hello World", "World") -// a.Contains(["Hello", "World"], "World") -// a.Contains({"Hello": "World"}, "Hello") +// a.Contains("Hello World", "World") +// a.Contains(["Hello", "World"], "World") +// a.Contains({"Hello": "World"}, "Hello") func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -43,9 +43,9 @@ func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs .. // Containsf asserts that the specified string, list(array, slice...) or map contains the // specified substring or element. // -// a.Containsf("Hello World", "World", "error message %s", "formatted") -// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted") -// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted") +// a.Containsf("Hello World", "World", "error message %s", "formatted") +// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted") +// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted") func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -98,7 +98,7 @@ func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg st // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either // a slice or a channel with len == 0. // -// a.Empty(obj) +// a.Empty(obj) func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -109,7 +109,7 @@ func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool { // Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either // a slice or a channel with len == 0. // -// a.Emptyf(obj, "error message %s", "formatted") +// a.Emptyf(obj, "error message %s", "formatted") func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -119,7 +119,7 @@ func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) // Equal asserts that two objects are equal. // -// a.Equal(123, 123) +// a.Equal(123, 123) // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). Function equality @@ -134,8 +134,8 @@ func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs // EqualError asserts that a function returned an error (i.e. not `nil`) // and that it is equal to the provided error. // -// actualObj, err := SomeFunction() -// a.EqualError(err, expectedErrorString) +// actualObj, err := SomeFunction() +// a.EqualError(err, expectedErrorString) func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -146,8 +146,8 @@ func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ... // EqualErrorf asserts that a function returned an error (i.e. not `nil`) // and that it is equal to the provided error. // -// actualObj, err := SomeFunction() -// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted") +// actualObj, err := SomeFunction() +// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted") func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -155,10 +155,44 @@ func (a *Assertions) EqualErrorf(theError error, errString string, msg string, a return EqualErrorf(a.t, theError, errString, msg, args...) } +// EqualExportedValues asserts that the types of two objects are equal and their public +// fields are also equal. This is useful for comparing structs that have private fields +// that could potentially differ. +// +// type S struct { +// Exported int +// notExported int +// } +// a.EqualExportedValues(S{1, 2}, S{1, 3}) => true +// a.EqualExportedValues(S{1, 2}, S{2, 3}) => false +func (a *Assertions) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return EqualExportedValues(a.t, expected, actual, msgAndArgs...) +} + +// EqualExportedValuesf asserts that the types of two objects are equal and their public +// fields are also equal. This is useful for comparing structs that have private fields +// that could potentially differ. +// +// type S struct { +// Exported int +// notExported int +// } +// a.EqualExportedValuesf(S{1, 2}, S{1, 3}, "error message %s", "formatted") => true +// a.EqualExportedValuesf(S{1, 2}, S{2, 3}, "error message %s", "formatted") => false +func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return EqualExportedValuesf(a.t, expected, actual, msg, args...) +} + // EqualValues asserts that two objects are equal or convertable to the same types // and equal. // -// a.EqualValues(uint32(123), int32(123)) +// a.EqualValues(uint32(123), int32(123)) func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -169,7 +203,7 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn // EqualValuesf asserts that two objects are equal or convertable to the same types // and equal. // -// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted") +// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted") func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -179,7 +213,7 @@ func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg // Equalf asserts that two objects are equal. // -// a.Equalf(123, 123, "error message %s", "formatted") +// a.Equalf(123, 123, "error message %s", "formatted") // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). Function equality @@ -193,10 +227,10 @@ func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string // Error asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if a.Error(err) { -// assert.Equal(t, expectedError, err) -// } +// actualObj, err := SomeFunction() +// if a.Error(err) { +// assert.Equal(t, expectedError, err) +// } func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -225,8 +259,8 @@ func (a *Assertions) ErrorAsf(err error, target interface{}, msg string, args .. // ErrorContains asserts that a function returned an error (i.e. not `nil`) // and that the error contains the specified substring. // -// actualObj, err := SomeFunction() -// a.ErrorContains(err, expectedErrorSubString) +// actualObj, err := SomeFunction() +// a.ErrorContains(err, expectedErrorSubString) func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -237,8 +271,8 @@ func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs . // ErrorContainsf asserts that a function returned an error (i.e. not `nil`) // and that the error contains the specified substring. // -// actualObj, err := SomeFunction() -// a.ErrorContainsf(err, expectedErrorSubString, "error message %s", "formatted") +// actualObj, err := SomeFunction() +// a.ErrorContainsf(err, expectedErrorSubString, "error message %s", "formatted") func (a *Assertions) ErrorContainsf(theError error, contains string, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -266,10 +300,10 @@ func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...inter // Errorf asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if a.Errorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } +// actualObj, err := SomeFunction() +// if a.Errorf(err, "error message %s", "formatted") { +// assert.Equal(t, expectedErrorf, err) +// } func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -280,7 +314,7 @@ func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool { // Eventually asserts that given condition will be met in waitFor time, // periodically checking target function each tick. // -// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond) +// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond) func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -288,10 +322,60 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti return Eventually(a.t, condition, waitFor, tick, msgAndArgs...) } +// EventuallyWithT asserts that given condition will be met in waitFor time, +// periodically checking target function each tick. In contrast to Eventually, +// it supplies a CollectT to the condition function, so that the condition +// function can use the CollectT to call other assertions. +// The condition is considered "met" if no errors are raised in a tick. +// The supplied CollectT collects all errors from one tick (if there are any). +// If the condition is not met before waitFor, the collected errors of +// the last tick are copied to t. +// +// externalValue := false +// go func() { +// time.Sleep(8*time.Second) +// externalValue = true +// }() +// a.EventuallyWithT(func(c *assert.CollectT) { +// // add assertions as needed; any assertion failure will fail the current tick +// assert.True(c, externalValue, "expected 'externalValue' to be true") +// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +func (a *Assertions) EventuallyWithT(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return EventuallyWithT(a.t, condition, waitFor, tick, msgAndArgs...) +} + +// EventuallyWithTf asserts that given condition will be met in waitFor time, +// periodically checking target function each tick. In contrast to Eventually, +// it supplies a CollectT to the condition function, so that the condition +// function can use the CollectT to call other assertions. +// The condition is considered "met" if no errors are raised in a tick. +// The supplied CollectT collects all errors from one tick (if there are any). +// If the condition is not met before waitFor, the collected errors of +// the last tick are copied to t. +// +// externalValue := false +// go func() { +// time.Sleep(8*time.Second) +// externalValue = true +// }() +// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") { +// // add assertions as needed; any assertion failure will fail the current tick +// assert.True(c, externalValue, "expected 'externalValue' to be true") +// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +func (a *Assertions) EventuallyWithTf(condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return EventuallyWithTf(a.t, condition, waitFor, tick, msg, args...) +} + // Eventuallyf asserts that given condition will be met in waitFor time, // periodically checking target function each tick. // -// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") +// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -301,7 +385,7 @@ func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, t // Exactly asserts that two objects are equal in value and type. // -// a.Exactly(int32(123), int64(123)) +// a.Exactly(int32(123), int64(123)) func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -311,7 +395,7 @@ func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArg // Exactlyf asserts that two objects are equal in value and type. // -// a.Exactlyf(int32(123), int64(123), "error message %s", "formatted") +// a.Exactlyf(int32(123), int64(123), "error message %s", "formatted") func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -353,7 +437,7 @@ func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{ // False asserts that the specified value is false. // -// a.False(myBool) +// a.False(myBool) func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -363,7 +447,7 @@ func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool { // Falsef asserts that the specified value is false. // -// a.Falsef(myBool, "error message %s", "formatted") +// a.Falsef(myBool, "error message %s", "formatted") func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -391,9 +475,9 @@ func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) b // Greater asserts that the first element is greater than the second // -// a.Greater(2, 1) -// a.Greater(float64(2), float64(1)) -// a.Greater("b", "a") +// a.Greater(2, 1) +// a.Greater(float64(2), float64(1)) +// a.Greater("b", "a") func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -403,10 +487,10 @@ func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...inter // GreaterOrEqual asserts that the first element is greater than or equal to the second // -// a.GreaterOrEqual(2, 1) -// a.GreaterOrEqual(2, 2) -// a.GreaterOrEqual("b", "a") -// a.GreaterOrEqual("b", "b") +// a.GreaterOrEqual(2, 1) +// a.GreaterOrEqual(2, 2) +// a.GreaterOrEqual("b", "a") +// a.GreaterOrEqual("b", "b") func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -416,10 +500,10 @@ func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs . // GreaterOrEqualf asserts that the first element is greater than or equal to the second // -// a.GreaterOrEqualf(2, 1, "error message %s", "formatted") -// a.GreaterOrEqualf(2, 2, "error message %s", "formatted") -// a.GreaterOrEqualf("b", "a", "error message %s", "formatted") -// a.GreaterOrEqualf("b", "b", "error message %s", "formatted") +// a.GreaterOrEqualf(2, 1, "error message %s", "formatted") +// a.GreaterOrEqualf(2, 2, "error message %s", "formatted") +// a.GreaterOrEqualf("b", "a", "error message %s", "formatted") +// a.GreaterOrEqualf("b", "b", "error message %s", "formatted") func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -429,9 +513,9 @@ func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, // Greaterf asserts that the first element is greater than the second // -// a.Greaterf(2, 1, "error message %s", "formatted") -// a.Greaterf(float64(2), float64(1), "error message %s", "formatted") -// a.Greaterf("b", "a", "error message %s", "formatted") +// a.Greaterf(2, 1, "error message %s", "formatted") +// a.Greaterf(float64(2), float64(1), "error message %s", "formatted") +// a.Greaterf("b", "a", "error message %s", "formatted") func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -442,7 +526,7 @@ func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args . // HTTPBodyContains asserts that a specified handler returns a // body that contains a string. // -// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { @@ -455,7 +539,7 @@ func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, u // HTTPBodyContainsf asserts that a specified handler returns a // body that contains a string. // -// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { @@ -468,7 +552,7 @@ func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, // HTTPBodyNotContains asserts that a specified handler returns a // body that does not contain a string. // -// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { @@ -481,7 +565,7 @@ func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string // HTTPBodyNotContainsf asserts that a specified handler returns a // body that does not contain a string. // -// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { @@ -493,7 +577,7 @@ func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method strin // HTTPError asserts that a specified handler returns an error status code. // -// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { @@ -505,7 +589,7 @@ func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url stri // HTTPErrorf asserts that a specified handler returns an error status code. // -// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { @@ -517,7 +601,7 @@ func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url str // HTTPRedirect asserts that a specified handler returns a redirect status code. // -// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { @@ -529,7 +613,7 @@ func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url s // HTTPRedirectf asserts that a specified handler returns a redirect status code. // -// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { @@ -541,7 +625,7 @@ func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url // HTTPStatusCode asserts that a specified handler returns a specified status code. // -// a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501) +// a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501) // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool { @@ -553,7 +637,7 @@ func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url // HTTPStatusCodef asserts that a specified handler returns a specified status code. // -// a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") +// a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool { @@ -565,7 +649,7 @@ func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, ur // HTTPSuccess asserts that a specified handler returns a success status code. // -// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) +// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { @@ -577,7 +661,7 @@ func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url st // HTTPSuccessf asserts that a specified handler returns a success status code. // -// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") +// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { @@ -589,7 +673,7 @@ func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url s // Implements asserts that an object is implemented by the specified interface. // -// a.Implements((*MyInterface)(nil), new(MyObject)) +// a.Implements((*MyInterface)(nil), new(MyObject)) func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -599,7 +683,7 @@ func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, // Implementsf asserts that an object is implemented by the specified interface. // -// a.Implementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted") +// a.Implementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted") func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -609,7 +693,7 @@ func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{} // InDelta asserts that the two numerals are within delta of each other. // -// a.InDelta(math.Pi, 22/7.0, 0.01) +// a.InDelta(math.Pi, 22/7.0, 0.01) func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -651,7 +735,7 @@ func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, del // InDeltaf asserts that the two numerals are within delta of each other. // -// a.InDeltaf(math.Pi, 22/7.0, 0.01, "error message %s", "formatted") +// a.InDeltaf(math.Pi, 22/7.0, 0.01, "error message %s", "formatted") func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -693,9 +777,9 @@ func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilo // IsDecreasing asserts that the collection is decreasing // -// a.IsDecreasing([]int{2, 1, 0}) -// a.IsDecreasing([]float{2, 1}) -// a.IsDecreasing([]string{"b", "a"}) +// a.IsDecreasing([]int{2, 1, 0}) +// a.IsDecreasing([]float{2, 1}) +// a.IsDecreasing([]string{"b", "a"}) func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -705,9 +789,9 @@ func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) // IsDecreasingf asserts that the collection is decreasing // -// a.IsDecreasingf([]int{2, 1, 0}, "error message %s", "formatted") -// a.IsDecreasingf([]float{2, 1}, "error message %s", "formatted") -// a.IsDecreasingf([]string{"b", "a"}, "error message %s", "formatted") +// a.IsDecreasingf([]int{2, 1, 0}, "error message %s", "formatted") +// a.IsDecreasingf([]float{2, 1}, "error message %s", "formatted") +// a.IsDecreasingf([]string{"b", "a"}, "error message %s", "formatted") func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -717,9 +801,9 @@ func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...inter // IsIncreasing asserts that the collection is increasing // -// a.IsIncreasing([]int{1, 2, 3}) -// a.IsIncreasing([]float{1, 2}) -// a.IsIncreasing([]string{"a", "b"}) +// a.IsIncreasing([]int{1, 2, 3}) +// a.IsIncreasing([]float{1, 2}) +// a.IsIncreasing([]string{"a", "b"}) func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -729,9 +813,9 @@ func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) // IsIncreasingf asserts that the collection is increasing // -// a.IsIncreasingf([]int{1, 2, 3}, "error message %s", "formatted") -// a.IsIncreasingf([]float{1, 2}, "error message %s", "formatted") -// a.IsIncreasingf([]string{"a", "b"}, "error message %s", "formatted") +// a.IsIncreasingf([]int{1, 2, 3}, "error message %s", "formatted") +// a.IsIncreasingf([]float{1, 2}, "error message %s", "formatted") +// a.IsIncreasingf([]string{"a", "b"}, "error message %s", "formatted") func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -741,9 +825,9 @@ func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...inter // IsNonDecreasing asserts that the collection is not decreasing // -// a.IsNonDecreasing([]int{1, 1, 2}) -// a.IsNonDecreasing([]float{1, 2}) -// a.IsNonDecreasing([]string{"a", "b"}) +// a.IsNonDecreasing([]int{1, 1, 2}) +// a.IsNonDecreasing([]float{1, 2}) +// a.IsNonDecreasing([]string{"a", "b"}) func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -753,9 +837,9 @@ func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface // IsNonDecreasingf asserts that the collection is not decreasing // -// a.IsNonDecreasingf([]int{1, 1, 2}, "error message %s", "formatted") -// a.IsNonDecreasingf([]float{1, 2}, "error message %s", "formatted") -// a.IsNonDecreasingf([]string{"a", "b"}, "error message %s", "formatted") +// a.IsNonDecreasingf([]int{1, 1, 2}, "error message %s", "formatted") +// a.IsNonDecreasingf([]float{1, 2}, "error message %s", "formatted") +// a.IsNonDecreasingf([]string{"a", "b"}, "error message %s", "formatted") func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -765,9 +849,9 @@ func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, args ...in // IsNonIncreasing asserts that the collection is not increasing // -// a.IsNonIncreasing([]int{2, 1, 1}) -// a.IsNonIncreasing([]float{2, 1}) -// a.IsNonIncreasing([]string{"b", "a"}) +// a.IsNonIncreasing([]int{2, 1, 1}) +// a.IsNonIncreasing([]float{2, 1}) +// a.IsNonIncreasing([]string{"b", "a"}) func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -777,9 +861,9 @@ func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface // IsNonIncreasingf asserts that the collection is not increasing // -// a.IsNonIncreasingf([]int{2, 1, 1}, "error message %s", "formatted") -// a.IsNonIncreasingf([]float{2, 1}, "error message %s", "formatted") -// a.IsNonIncreasingf([]string{"b", "a"}, "error message %s", "formatted") +// a.IsNonIncreasingf([]int{2, 1, 1}, "error message %s", "formatted") +// a.IsNonIncreasingf([]float{2, 1}, "error message %s", "formatted") +// a.IsNonIncreasingf([]string{"b", "a"}, "error message %s", "formatted") func (a *Assertions) IsNonIncreasingf(object interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -805,7 +889,7 @@ func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg s // JSONEq asserts that two JSON strings are equivalent. // -// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) +// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -815,7 +899,7 @@ func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interf // JSONEqf asserts that two JSON strings are equivalent. // -// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") +// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -826,7 +910,7 @@ func (a *Assertions) JSONEqf(expected string, actual string, msg string, args .. // Len asserts that the specified object has specific length. // Len also fails if the object has a type that len() not accept. // -// a.Len(mySlice, 3) +// a.Len(mySlice, 3) func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -837,7 +921,7 @@ func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface // Lenf asserts that the specified object has specific length. // Lenf also fails if the object has a type that len() not accept. // -// a.Lenf(mySlice, 3, "error message %s", "formatted") +// a.Lenf(mySlice, 3, "error message %s", "formatted") func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -847,9 +931,9 @@ func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...in // Less asserts that the first element is less than the second // -// a.Less(1, 2) -// a.Less(float64(1), float64(2)) -// a.Less("a", "b") +// a.Less(1, 2) +// a.Less(float64(1), float64(2)) +// a.Less("a", "b") func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -859,10 +943,10 @@ func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interfac // LessOrEqual asserts that the first element is less than or equal to the second // -// a.LessOrEqual(1, 2) -// a.LessOrEqual(2, 2) -// a.LessOrEqual("a", "b") -// a.LessOrEqual("b", "b") +// a.LessOrEqual(1, 2) +// a.LessOrEqual(2, 2) +// a.LessOrEqual("a", "b") +// a.LessOrEqual("b", "b") func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -872,10 +956,10 @@ func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...i // LessOrEqualf asserts that the first element is less than or equal to the second // -// a.LessOrEqualf(1, 2, "error message %s", "formatted") -// a.LessOrEqualf(2, 2, "error message %s", "formatted") -// a.LessOrEqualf("a", "b", "error message %s", "formatted") -// a.LessOrEqualf("b", "b", "error message %s", "formatted") +// a.LessOrEqualf(1, 2, "error message %s", "formatted") +// a.LessOrEqualf(2, 2, "error message %s", "formatted") +// a.LessOrEqualf("a", "b", "error message %s", "formatted") +// a.LessOrEqualf("b", "b", "error message %s", "formatted") func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -885,9 +969,9 @@ func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, ar // Lessf asserts that the first element is less than the second // -// a.Lessf(1, 2, "error message %s", "formatted") -// a.Lessf(float64(1), float64(2), "error message %s", "formatted") -// a.Lessf("a", "b", "error message %s", "formatted") +// a.Lessf(1, 2, "error message %s", "formatted") +// a.Lessf(float64(1), float64(2), "error message %s", "formatted") +// a.Lessf("a", "b", "error message %s", "formatted") func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -897,8 +981,8 @@ func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...i // Negative asserts that the specified element is negative // -// a.Negative(-1) -// a.Negative(-1.23) +// a.Negative(-1) +// a.Negative(-1.23) func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -908,8 +992,8 @@ func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) bool { // Negativef asserts that the specified element is negative // -// a.Negativef(-1, "error message %s", "formatted") -// a.Negativef(-1.23, "error message %s", "formatted") +// a.Negativef(-1, "error message %s", "formatted") +// a.Negativef(-1.23, "error message %s", "formatted") func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -920,7 +1004,7 @@ func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) b // Never asserts that the given condition doesn't satisfy in waitFor time, // periodically checking the target function each tick. // -// a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond) +// a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond) func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -931,7 +1015,7 @@ func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick ti // Neverf asserts that the given condition doesn't satisfy in waitFor time, // periodically checking the target function each tick. // -// a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") +// a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -941,7 +1025,7 @@ func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick t // Nil asserts that the specified object is nil. // -// a.Nil(err) +// a.Nil(err) func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -951,7 +1035,7 @@ func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool { // Nilf asserts that the specified object is nil. // -// a.Nilf(err, "error message %s", "formatted") +// a.Nilf(err, "error message %s", "formatted") func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -979,10 +1063,10 @@ func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) // NoError asserts that a function returned no error (i.e. `nil`). // -// actualObj, err := SomeFunction() -// if a.NoError(err) { -// assert.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// if a.NoError(err) { +// assert.Equal(t, expectedObj, actualObj) +// } func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -992,10 +1076,10 @@ func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool { // NoErrorf asserts that a function returned no error (i.e. `nil`). // -// actualObj, err := SomeFunction() -// if a.NoErrorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// if a.NoErrorf(err, "error message %s", "formatted") { +// assert.Equal(t, expectedObj, actualObj) +// } func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1024,9 +1108,9 @@ func (a *Assertions) NoFileExistsf(path string, msg string, args ...interface{}) // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // -// a.NotContains("Hello World", "Earth") -// a.NotContains(["Hello", "World"], "Earth") -// a.NotContains({"Hello": "World"}, "Earth") +// a.NotContains("Hello World", "Earth") +// a.NotContains(["Hello", "World"], "Earth") +// a.NotContains({"Hello": "World"}, "Earth") func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1037,9 +1121,9 @@ func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs // NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // -// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted") -// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted") -// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted") +// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted") +// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted") +// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted") func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1050,9 +1134,9 @@ func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg strin // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // -// if a.NotEmpty(obj) { -// assert.Equal(t, "two", obj[1]) -// } +// if a.NotEmpty(obj) { +// assert.Equal(t, "two", obj[1]) +// } func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1063,9 +1147,9 @@ func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) boo // NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // -// if a.NotEmptyf(obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } +// if a.NotEmptyf(obj, "error message %s", "formatted") { +// assert.Equal(t, "two", obj[1]) +// } func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1075,7 +1159,7 @@ func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface // NotEqual asserts that the specified values are NOT equal. // -// a.NotEqual(obj1, obj2) +// a.NotEqual(obj1, obj2) // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). @@ -1088,7 +1172,7 @@ func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndAr // NotEqualValues asserts that two objects are not equal even when converted to the same type // -// a.NotEqualValues(obj1, obj2) +// a.NotEqualValues(obj1, obj2) func (a *Assertions) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1098,7 +1182,7 @@ func (a *Assertions) NotEqualValues(expected interface{}, actual interface{}, ms // NotEqualValuesf asserts that two objects are not equal even when converted to the same type // -// a.NotEqualValuesf(obj1, obj2, "error message %s", "formatted") +// a.NotEqualValuesf(obj1, obj2, "error message %s", "formatted") func (a *Assertions) NotEqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1108,7 +1192,7 @@ func (a *Assertions) NotEqualValuesf(expected interface{}, actual interface{}, m // NotEqualf asserts that the specified values are NOT equal. // -// a.NotEqualf(obj1, obj2, "error message %s", "formatted") +// a.NotEqualf(obj1, obj2, "error message %s", "formatted") // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). @@ -1139,7 +1223,7 @@ func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...in // NotNil asserts that the specified object is not nil. // -// a.NotNil(err) +// a.NotNil(err) func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1149,7 +1233,7 @@ func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool // NotNilf asserts that the specified object is not nil. // -// a.NotNilf(err, "error message %s", "formatted") +// a.NotNilf(err, "error message %s", "formatted") func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1159,7 +1243,7 @@ func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{} // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. // -// a.NotPanics(func(){ RemainCalm() }) +// a.NotPanics(func(){ RemainCalm() }) func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1169,7 +1253,7 @@ func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool // NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. // -// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted") +// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted") func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1179,8 +1263,8 @@ func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{} // NotRegexp asserts that a specified regexp does not match a string. // -// a.NotRegexp(regexp.MustCompile("starts"), "it's starting") -// a.NotRegexp("^start", "it's not starting") +// a.NotRegexp(regexp.MustCompile("starts"), "it's starting") +// a.NotRegexp("^start", "it's not starting") func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1190,8 +1274,8 @@ func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...in // NotRegexpf asserts that a specified regexp does not match a string. // -// a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") -// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") +// a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") +// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1201,7 +1285,7 @@ func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, arg // NotSame asserts that two pointers do not reference the same object. // -// a.NotSame(ptr1, ptr2) +// a.NotSame(ptr1, ptr2) // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1214,7 +1298,7 @@ func (a *Assertions) NotSame(expected interface{}, actual interface{}, msgAndArg // NotSamef asserts that two pointers do not reference the same object. // -// a.NotSamef(ptr1, ptr2, "error message %s", "formatted") +// a.NotSamef(ptr1, ptr2, "error message %s", "formatted") // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1228,7 +1312,7 @@ func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg stri // NotSubset asserts that the specified list(array, slice...) contains not all // elements given in the specified subset(array, slice...). // -// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1239,7 +1323,7 @@ func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs // NotSubsetf asserts that the specified list(array, slice...) contains not all // elements given in the specified subset(array, slice...). // -// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1265,7 +1349,7 @@ func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bo // Panics asserts that the code inside the specified PanicTestFunc panics. // -// a.Panics(func(){ GoCrazy() }) +// a.Panics(func(){ GoCrazy() }) func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1277,7 +1361,7 @@ func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool { // panics, and that the recovered panic value is an error that satisfies the // EqualError comparison. // -// a.PanicsWithError("crazy error", func(){ GoCrazy() }) +// a.PanicsWithError("crazy error", func(){ GoCrazy() }) func (a *Assertions) PanicsWithError(errString string, f PanicTestFunc, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1289,7 +1373,7 @@ func (a *Assertions) PanicsWithError(errString string, f PanicTestFunc, msgAndAr // panics, and that the recovered panic value is an error that satisfies the // EqualError comparison. // -// a.PanicsWithErrorf("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +// a.PanicsWithErrorf("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") func (a *Assertions) PanicsWithErrorf(errString string, f PanicTestFunc, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1300,7 +1384,7 @@ func (a *Assertions) PanicsWithErrorf(errString string, f PanicTestFunc, msg str // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that // the recovered panic value equals the expected panic value. // -// a.PanicsWithValue("crazy error", func(){ GoCrazy() }) +// a.PanicsWithValue("crazy error", func(){ GoCrazy() }) func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1311,7 +1395,7 @@ func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgA // PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that // the recovered panic value equals the expected panic value. // -// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1321,7 +1405,7 @@ func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg // Panicsf asserts that the code inside the specified PanicTestFunc panics. // -// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted") +// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted") func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1331,8 +1415,8 @@ func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) b // Positive asserts that the specified element is positive // -// a.Positive(1) -// a.Positive(1.23) +// a.Positive(1) +// a.Positive(1.23) func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1342,8 +1426,8 @@ func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) bool { // Positivef asserts that the specified element is positive // -// a.Positivef(1, "error message %s", "formatted") -// a.Positivef(1.23, "error message %s", "formatted") +// a.Positivef(1, "error message %s", "formatted") +// a.Positivef(1.23, "error message %s", "formatted") func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1353,8 +1437,8 @@ func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) b // Regexp asserts that a specified regexp matches a string. // -// a.Regexp(regexp.MustCompile("start"), "it's starting") -// a.Regexp("start...$", "it's not starting") +// a.Regexp(regexp.MustCompile("start"), "it's starting") +// a.Regexp("start...$", "it's not starting") func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1364,8 +1448,8 @@ func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...inter // Regexpf asserts that a specified regexp matches a string. // -// a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") -// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") +// a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") +// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1375,7 +1459,7 @@ func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args . // Same asserts that two pointers reference the same object. // -// a.Same(ptr1, ptr2) +// a.Same(ptr1, ptr2) // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1388,7 +1472,7 @@ func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs . // Samef asserts that two pointers reference the same object. // -// a.Samef(ptr1, ptr2, "error message %s", "formatted") +// a.Samef(ptr1, ptr2, "error message %s", "formatted") // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1402,7 +1486,7 @@ func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, // Subset asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // -// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1413,7 +1497,7 @@ func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ... // Subsetf asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // -// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1423,7 +1507,7 @@ func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, a // True asserts that the specified value is true. // -// a.True(myBool) +// a.True(myBool) func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1433,7 +1517,7 @@ func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool { // Truef asserts that the specified value is true. // -// a.Truef(myBool, "error message %s", "formatted") +// a.Truef(myBool, "error message %s", "formatted") func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1443,7 +1527,7 @@ func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool { // WithinDuration asserts that the two times are within duration delta of each other. // -// a.WithinDuration(time.Now(), time.Now(), 10*time.Second) +// a.WithinDuration(time.Now(), time.Now(), 10*time.Second) func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1453,7 +1537,7 @@ func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta // WithinDurationf asserts that the two times are within duration delta of each other. // -// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") +// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1461,6 +1545,26 @@ func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta return WithinDurationf(a.t, expected, actual, delta, msg, args...) } +// WithinRange asserts that a time is within a time range (inclusive). +// +// a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second)) +func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return WithinRange(a.t, actual, start, end, msgAndArgs...) +} + +// WithinRangef asserts that a time is within a time range (inclusive). +// +// a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted") +func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return WithinRangef(a.t, actual, start, end, msg, args...) +} + // YAMLEq asserts that two YAML strings are equivalent. func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { diff --git a/vendor/github.com/stretchr/testify/assert/assertion_order.go b/vendor/github.com/stretchr/testify/assert/assertion_order.go index 75944878..00df62a0 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_order.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_order.go @@ -46,36 +46,36 @@ func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareT // IsIncreasing asserts that the collection is increasing // -// assert.IsIncreasing(t, []int{1, 2, 3}) -// assert.IsIncreasing(t, []float{1, 2}) -// assert.IsIncreasing(t, []string{"a", "b"}) +// assert.IsIncreasing(t, []int{1, 2, 3}) +// assert.IsIncreasing(t, []float{1, 2}) +// assert.IsIncreasing(t, []string{"a", "b"}) func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { return isOrdered(t, object, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...) } // IsNonIncreasing asserts that the collection is not increasing // -// assert.IsNonIncreasing(t, []int{2, 1, 1}) -// assert.IsNonIncreasing(t, []float{2, 1}) -// assert.IsNonIncreasing(t, []string{"b", "a"}) +// assert.IsNonIncreasing(t, []int{2, 1, 1}) +// assert.IsNonIncreasing(t, []float{2, 1}) +// assert.IsNonIncreasing(t, []string{"b", "a"}) func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { return isOrdered(t, object, []CompareType{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...) } // IsDecreasing asserts that the collection is decreasing // -// assert.IsDecreasing(t, []int{2, 1, 0}) -// assert.IsDecreasing(t, []float{2, 1}) -// assert.IsDecreasing(t, []string{"b", "a"}) +// assert.IsDecreasing(t, []int{2, 1, 0}) +// assert.IsDecreasing(t, []float{2, 1}) +// assert.IsDecreasing(t, []string{"b", "a"}) func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { return isOrdered(t, object, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...) } // IsNonDecreasing asserts that the collection is not decreasing // -// assert.IsNonDecreasing(t, []int{1, 1, 2}) -// assert.IsNonDecreasing(t, []float{1, 2}) -// assert.IsNonDecreasing(t, []string{"a", "b"}) +// assert.IsNonDecreasing(t, []int{1, 1, 2}) +// assert.IsNonDecreasing(t, []float{1, 2}) +// assert.IsNonDecreasing(t, []string{"a", "b"}) func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { return isOrdered(t, object, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...) } diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go index 0357b223..a55d1bba 100644 --- a/vendor/github.com/stretchr/testify/assert/assertions.go +++ b/vendor/github.com/stretchr/testify/assert/assertions.go @@ -75,6 +75,77 @@ func ObjectsAreEqual(expected, actual interface{}) bool { return bytes.Equal(exp, act) } +// copyExportedFields iterates downward through nested data structures and creates a copy +// that only contains the exported struct fields. +func copyExportedFields(expected interface{}) interface{} { + if isNil(expected) { + return expected + } + + expectedType := reflect.TypeOf(expected) + expectedKind := expectedType.Kind() + expectedValue := reflect.ValueOf(expected) + + switch expectedKind { + case reflect.Struct: + result := reflect.New(expectedType).Elem() + for i := 0; i < expectedType.NumField(); i++ { + field := expectedType.Field(i) + isExported := field.IsExported() + if isExported { + fieldValue := expectedValue.Field(i) + if isNil(fieldValue) || isNil(fieldValue.Interface()) { + continue + } + newValue := copyExportedFields(fieldValue.Interface()) + result.Field(i).Set(reflect.ValueOf(newValue)) + } + } + return result.Interface() + + case reflect.Ptr: + result := reflect.New(expectedType.Elem()) + unexportedRemoved := copyExportedFields(expectedValue.Elem().Interface()) + result.Elem().Set(reflect.ValueOf(unexportedRemoved)) + return result.Interface() + + case reflect.Array, reflect.Slice: + result := reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len()) + for i := 0; i < expectedValue.Len(); i++ { + index := expectedValue.Index(i) + if isNil(index) { + continue + } + unexportedRemoved := copyExportedFields(index.Interface()) + result.Index(i).Set(reflect.ValueOf(unexportedRemoved)) + } + return result.Interface() + + case reflect.Map: + result := reflect.MakeMap(expectedType) + for _, k := range expectedValue.MapKeys() { + index := expectedValue.MapIndex(k) + unexportedRemoved := copyExportedFields(index.Interface()) + result.SetMapIndex(k, reflect.ValueOf(unexportedRemoved)) + } + return result.Interface() + + default: + return expected + } +} + +// ObjectsExportedFieldsAreEqual determines if the exported (public) fields of two objects are +// considered equal. This comparison of only exported fields is applied recursively to nested data +// structures. +// +// This function does no assertion of any kind. +func ObjectsExportedFieldsAreEqual(expected, actual interface{}) bool { + expectedCleaned := copyExportedFields(expected) + actualCleaned := copyExportedFields(actual) + return ObjectsAreEqualValues(expectedCleaned, actualCleaned) +} + // ObjectsAreEqualValues gets whether two objects are equal, or if their // values are equal. func ObjectsAreEqualValues(expected, actual interface{}) bool { @@ -140,10 +211,10 @@ func CallerInfo() []string { } parts := strings.Split(file, "/") - file = parts[len(parts)-1] if len(parts) > 1 { + filename := parts[len(parts)-1] dir := parts[len(parts)-2] - if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" { + if (dir != "assert" && dir != "mock" && dir != "require") || filename == "mock_test.go" { callers = append(callers, fmt.Sprintf("%s:%d", file, line)) } } @@ -271,7 +342,7 @@ type labeledContent struct { // labeledOutput returns a string consisting of the provided labeledContent. Each labeled output is appended in the following manner: // -// \t{{label}}:{{align_spaces}}\t{{content}}\n +// \t{{label}}:{{align_spaces}}\t{{content}}\n // // The initial carriage return is required to undo/erase any padding added by testing.T.Errorf. The "\t{{label}}:" is for the label. // If a label is shorter than the longest label provided, padding spaces are added to make all the labels match in length. Once this @@ -294,7 +365,7 @@ func labeledOutput(content ...labeledContent) string { // Implements asserts that an object is implemented by the specified interface. // -// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) +// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -326,7 +397,7 @@ func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs // Equal asserts that two objects are equal. // -// assert.Equal(t, 123, 123) +// assert.Equal(t, 123, 123) // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). Function equality @@ -367,7 +438,7 @@ func validateEqualArgs(expected, actual interface{}) error { // Same asserts that two pointers reference the same object. // -// assert.Same(t, ptr1, ptr2) +// assert.Same(t, ptr1, ptr2) // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -387,7 +458,7 @@ func Same(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) b // NotSame asserts that two pointers do not reference the same object. // -// assert.NotSame(t, ptr1, ptr2) +// assert.NotSame(t, ptr1, ptr2) // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -455,7 +526,7 @@ func truncatingFormat(data interface{}) string { // EqualValues asserts that two objects are equal or convertable to the same types // and equal. // -// assert.EqualValues(t, uint32(123), int32(123)) +// assert.EqualValues(t, uint32(123), int32(123)) func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -473,9 +544,53 @@ func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interfa } +// EqualExportedValues asserts that the types of two objects are equal and their public +// fields are also equal. This is useful for comparing structs that have private fields +// that could potentially differ. +// +// type S struct { +// Exported int +// notExported int +// } +// assert.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true +// assert.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false +func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + + aType := reflect.TypeOf(expected) + bType := reflect.TypeOf(actual) + + if aType != bType { + return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...) + } + + if aType.Kind() != reflect.Struct { + return Fail(t, fmt.Sprintf("Types expected to both be struct \n\t%v != %v", aType.Kind(), reflect.Struct), msgAndArgs...) + } + + if bType.Kind() != reflect.Struct { + return Fail(t, fmt.Sprintf("Types expected to both be struct \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...) + } + + expected = copyExportedFields(expected) + actual = copyExportedFields(actual) + + if !ObjectsAreEqualValues(expected, actual) { + diff := diff(expected, actual) + expected, actual = formatUnequalValues(expected, actual) + return Fail(t, fmt.Sprintf("Not equal (comparing only exported fields): \n"+ + "expected: %s\n"+ + "actual : %s%s", expected, actual, diff), msgAndArgs...) + } + + return true +} + // Exactly asserts that two objects are equal in value and type. // -// assert.Exactly(t, int32(123), int64(123)) +// assert.Exactly(t, int32(123), int64(123)) func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -494,7 +609,7 @@ func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{} // NotNil asserts that the specified object is not nil. // -// assert.NotNil(t, err) +// assert.NotNil(t, err) func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { if !isNil(object) { return true @@ -528,7 +643,7 @@ func isNil(object interface{}) bool { []reflect.Kind{ reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, - reflect.Ptr, reflect.Slice}, + reflect.Ptr, reflect.Slice, reflect.UnsafePointer}, kind) if isNilableKind && value.IsNil() { @@ -540,7 +655,7 @@ func isNil(object interface{}) bool { // Nil asserts that the specified object is nil. // -// assert.Nil(t, err) +// assert.Nil(t, err) func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { if isNil(object) { return true @@ -563,16 +678,17 @@ func isEmpty(object interface{}) bool { switch objValue.Kind() { // collection types are empty when they have no element - case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: + case reflect.Chan, reflect.Map, reflect.Slice: return objValue.Len() == 0 - // pointers are empty if nil or if the value they point to is empty + // pointers are empty if nil or if the value they point to is empty case reflect.Ptr: if objValue.IsNil() { return true } deref := objValue.Elem().Interface() return isEmpty(deref) - // for all other types, compare against the zero value + // for all other types, compare against the zero value + // array types are empty when they match their zero-initialized state default: zero := reflect.Zero(objValue.Type()) return reflect.DeepEqual(object, zero.Interface()) @@ -582,7 +698,7 @@ func isEmpty(object interface{}) bool { // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either // a slice or a channel with len == 0. // -// assert.Empty(t, obj) +// assert.Empty(t, obj) func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { pass := isEmpty(object) if !pass { @@ -599,9 +715,9 @@ func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // -// if assert.NotEmpty(t, obj) { -// assert.Equal(t, "two", obj[1]) -// } +// if assert.NotEmpty(t, obj) { +// assert.Equal(t, "two", obj[1]) +// } func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { pass := !isEmpty(object) if !pass { @@ -630,7 +746,7 @@ func getLen(x interface{}) (ok bool, length int) { // Len asserts that the specified object has specific length. // Len also fails if the object has a type that len() not accept. // -// assert.Len(t, mySlice, 3) +// assert.Len(t, mySlice, 3) func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -648,7 +764,7 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) // True asserts that the specified value is true. // -// assert.True(t, myBool) +// assert.True(t, myBool) func True(t TestingT, value bool, msgAndArgs ...interface{}) bool { if !value { if h, ok := t.(tHelper); ok { @@ -663,7 +779,7 @@ func True(t TestingT, value bool, msgAndArgs ...interface{}) bool { // False asserts that the specified value is false. // -// assert.False(t, myBool) +// assert.False(t, myBool) func False(t TestingT, value bool, msgAndArgs ...interface{}) bool { if value { if h, ok := t.(tHelper); ok { @@ -678,7 +794,7 @@ func False(t TestingT, value bool, msgAndArgs ...interface{}) bool { // NotEqual asserts that the specified values are NOT equal. // -// assert.NotEqual(t, obj1, obj2) +// assert.NotEqual(t, obj1, obj2) // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). @@ -701,7 +817,7 @@ func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{ // NotEqualValues asserts that two objects are not equal even when converted to the same type // -// assert.NotEqualValues(t, obj1, obj2) +// assert.NotEqualValues(t, obj1, obj2) func NotEqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -760,9 +876,9 @@ func containsElement(list interface{}, element interface{}) (ok, found bool) { // Contains asserts that the specified string, list(array, slice...) or map contains the // specified substring or element. // -// assert.Contains(t, "Hello World", "World") -// assert.Contains(t, ["Hello", "World"], "World") -// assert.Contains(t, {"Hello": "World"}, "Hello") +// assert.Contains(t, "Hello World", "World") +// assert.Contains(t, ["Hello", "World"], "World") +// assert.Contains(t, {"Hello": "World"}, "Hello") func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -783,9 +899,9 @@ func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bo // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // -// assert.NotContains(t, "Hello World", "Earth") -// assert.NotContains(t, ["Hello", "World"], "Earth") -// assert.NotContains(t, {"Hello": "World"}, "Earth") +// assert.NotContains(t, "Hello World", "Earth") +// assert.NotContains(t, ["Hello", "World"], "Earth") +// assert.NotContains(t, {"Hello": "World"}, "Earth") func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -793,10 +909,10 @@ func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) ok, found := containsElement(s, contains) if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", s), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", s), msgAndArgs...) } if found { - return Fail(t, fmt.Sprintf("\"%s\" should not contain \"%s\"", s, contains), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v should not contain %#v", s, contains), msgAndArgs...) } return true @@ -806,7 +922,7 @@ func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) // Subset asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // -// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) { if h, ok := t.(tHelper); ok { h.Helper() @@ -815,32 +931,44 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok return true // we consider nil to be equal to the nil set } - subsetValue := reflect.ValueOf(subset) - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - listKind := reflect.TypeOf(list).Kind() - subsetKind := reflect.TypeOf(subset).Kind() - - if listKind != reflect.Array && listKind != reflect.Slice { + if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) } - if subsetKind != reflect.Array && subsetKind != reflect.Slice { + subsetKind := reflect.TypeOf(subset).Kind() + if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) } - for i := 0; i < subsetValue.Len(); i++ { - element := subsetValue.Index(i).Interface() + if subsetKind == reflect.Map && listKind == reflect.Map { + subsetMap := reflect.ValueOf(subset) + actualMap := reflect.ValueOf(list) + + for _, k := range subsetMap.MapKeys() { + ev := subsetMap.MapIndex(k) + av := actualMap.MapIndex(k) + + if !av.IsValid() { + return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, subset), msgAndArgs...) + } + if !ObjectsAreEqual(ev.Interface(), av.Interface()) { + return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, subset), msgAndArgs...) + } + } + + return true + } + + subsetList := reflect.ValueOf(subset) + for i := 0; i < subsetList.Len(); i++ { + element := subsetList.Index(i).Interface() ok, found := containsElement(list, element) if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v could not be applied builtin len()", list), msgAndArgs...) } if !found { - return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, element), msgAndArgs...) + return Fail(t, fmt.Sprintf("%#v does not contain %#v", list, element), msgAndArgs...) } } @@ -850,7 +978,7 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok // NotSubset asserts that the specified list(array, slice...) contains not all // elements given in the specified subset(array, slice...). // -// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) { if h, ok := t.(tHelper); ok { h.Helper() @@ -859,26 +987,38 @@ func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) return Fail(t, "nil is the empty set which is a subset of every set", msgAndArgs...) } - subsetValue := reflect.ValueOf(subset) - defer func() { - if e := recover(); e != nil { - ok = false - } - }() - listKind := reflect.TypeOf(list).Kind() - subsetKind := reflect.TypeOf(subset).Kind() - - if listKind != reflect.Array && listKind != reflect.Slice { + if listKind != reflect.Array && listKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) } - if subsetKind != reflect.Array && subsetKind != reflect.Slice { + subsetKind := reflect.TypeOf(subset).Kind() + if subsetKind != reflect.Array && subsetKind != reflect.Slice && listKind != reflect.Map { return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) } - for i := 0; i < subsetValue.Len(); i++ { - element := subsetValue.Index(i).Interface() + if subsetKind == reflect.Map && listKind == reflect.Map { + subsetMap := reflect.ValueOf(subset) + actualMap := reflect.ValueOf(list) + + for _, k := range subsetMap.MapKeys() { + ev := subsetMap.MapIndex(k) + av := actualMap.MapIndex(k) + + if !av.IsValid() { + return true + } + if !ObjectsAreEqual(ev.Interface(), av.Interface()) { + return true + } + } + + return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...) + } + + subsetList := reflect.ValueOf(subset) + for i := 0; i < subsetList.Len(); i++ { + element := subsetList.Index(i).Interface() ok, found := containsElement(list, element) if !ok { return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) @@ -1023,7 +1163,7 @@ func didPanic(f PanicTestFunc) (didPanic bool, message interface{}, stack string // Panics asserts that the code inside the specified PanicTestFunc panics. // -// assert.Panics(t, func(){ GoCrazy() }) +// assert.Panics(t, func(){ GoCrazy() }) func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1039,7 +1179,7 @@ func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that // the recovered panic value equals the expected panic value. // -// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) +// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1060,7 +1200,7 @@ func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, msgAndAr // panics, and that the recovered panic value is an error that satisfies the // EqualError comparison. // -// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() }) +// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() }) func PanicsWithError(t TestingT, errString string, f PanicTestFunc, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1080,7 +1220,7 @@ func PanicsWithError(t TestingT, errString string, f PanicTestFunc, msgAndArgs . // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. // -// assert.NotPanics(t, func(){ RemainCalm() }) +// assert.NotPanics(t, func(){ RemainCalm() }) func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1095,7 +1235,7 @@ func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { // WithinDuration asserts that the two times are within duration delta of each other. // -// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) +// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1109,6 +1249,27 @@ func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, return true } +// WithinRange asserts that a time is within a time range (inclusive). +// +// assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second)) +func WithinRange(t TestingT, actual, start, end time.Time, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + + if end.Before(start) { + return Fail(t, "Start should be before end", msgAndArgs...) + } + + if actual.Before(start) { + return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is before the range", actual, start, end), msgAndArgs...) + } else if actual.After(end) { + return Fail(t, fmt.Sprintf("Time %v expected to be in time range %v to %v, but is after the range", actual, start, end), msgAndArgs...) + } + + return true +} + func toFloat(x interface{}) (float64, bool) { var xf float64 xok := true @@ -1149,7 +1310,7 @@ func toFloat(x interface{}) (float64, bool) { // InDelta asserts that the two numerals are within delta of each other. // -// assert.InDelta(t, math.Pi, 22/7.0, 0.01) +// assert.InDelta(t, math.Pi, 22/7.0, 0.01) func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1322,10 +1483,10 @@ func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, m // NoError asserts that a function returned no error (i.e. `nil`). // -// actualObj, err := SomeFunction() -// if assert.NoError(t, err) { -// assert.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// if assert.NoError(t, err) { +// assert.Equal(t, expectedObj, actualObj) +// } func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool { if err != nil { if h, ok := t.(tHelper); ok { @@ -1339,10 +1500,10 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool { // Error asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if assert.Error(t, err) { -// assert.Equal(t, expectedError, err) -// } +// actualObj, err := SomeFunction() +// if assert.Error(t, err) { +// assert.Equal(t, expectedError, err) +// } func Error(t TestingT, err error, msgAndArgs ...interface{}) bool { if err == nil { if h, ok := t.(tHelper); ok { @@ -1357,8 +1518,8 @@ func Error(t TestingT, err error, msgAndArgs ...interface{}) bool { // EqualError asserts that a function returned an error (i.e. not `nil`) // and that it is equal to the provided error. // -// actualObj, err := SomeFunction() -// assert.EqualError(t, err, expectedErrorString) +// actualObj, err := SomeFunction() +// assert.EqualError(t, err, expectedErrorString) func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1380,8 +1541,8 @@ func EqualError(t TestingT, theError error, errString string, msgAndArgs ...inte // ErrorContains asserts that a function returned an error (i.e. not `nil`) // and that the error contains the specified substring. // -// actualObj, err := SomeFunction() -// assert.ErrorContains(t, err, expectedErrorSubString) +// actualObj, err := SomeFunction() +// assert.ErrorContains(t, err, expectedErrorSubString) func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1414,8 +1575,8 @@ func matchRegexp(rx interface{}, str interface{}) bool { // Regexp asserts that a specified regexp matches a string. // -// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") -// assert.Regexp(t, "start...$", "it's not starting") +// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") +// assert.Regexp(t, "start...$", "it's not starting") func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1432,8 +1593,8 @@ func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface // NotRegexp asserts that a specified regexp does not match a string. // -// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") -// assert.NotRegexp(t, "^start", "it's not starting") +// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") +// assert.NotRegexp(t, "^start", "it's not starting") func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1545,7 +1706,7 @@ func NoDirExists(t TestingT, path string, msgAndArgs ...interface{}) bool { // JSONEq asserts that two JSON strings are equivalent. // -// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) +// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1668,7 +1829,7 @@ type tHelper interface { // Eventually asserts that given condition will be met in waitFor time, // periodically checking target function each tick. // -// assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond) +// assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond) func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -1698,10 +1859,93 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t } } +// CollectT implements the TestingT interface and collects all errors. +type CollectT struct { + errors []error +} + +// Errorf collects the error. +func (c *CollectT) Errorf(format string, args ...interface{}) { + c.errors = append(c.errors, fmt.Errorf(format, args...)) +} + +// FailNow panics. +func (c *CollectT) FailNow() { + panic("Assertion failed") +} + +// Reset clears the collected errors. +func (c *CollectT) Reset() { + c.errors = nil +} + +// Copy copies the collected errors to the supplied t. +func (c *CollectT) Copy(t TestingT) { + if tt, ok := t.(tHelper); ok { + tt.Helper() + } + for _, err := range c.errors { + t.Errorf("%v", err) + } +} + +// EventuallyWithT asserts that given condition will be met in waitFor time, +// periodically checking target function each tick. In contrast to Eventually, +// it supplies a CollectT to the condition function, so that the condition +// function can use the CollectT to call other assertions. +// The condition is considered "met" if no errors are raised in a tick. +// The supplied CollectT collects all errors from one tick (if there are any). +// If the condition is not met before waitFor, the collected errors of +// the last tick are copied to t. +// +// externalValue := false +// go func() { +// time.Sleep(8*time.Second) +// externalValue = true +// }() +// assert.EventuallyWithT(t, func(c *assert.CollectT) { +// // add assertions as needed; any assertion failure will fail the current tick +// assert.True(c, externalValue, "expected 'externalValue' to be true") +// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + + collect := new(CollectT) + ch := make(chan bool, 1) + + timer := time.NewTimer(waitFor) + defer timer.Stop() + + ticker := time.NewTicker(tick) + defer ticker.Stop() + + for tick := ticker.C; ; { + select { + case <-timer.C: + collect.Copy(t) + return Fail(t, "Condition never satisfied", msgAndArgs...) + case <-tick: + tick = nil + collect.Reset() + go func() { + condition(collect) + ch <- len(collect.errors) == 0 + }() + case v := <-ch: + if v { + return true + } + tick = ticker.C + } + } +} + // Never asserts that the given condition doesn't satisfy in waitFor time, // periodically checking the target function each tick. // -// assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond) +// assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond) func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/vendor/github.com/stretchr/testify/assert/doc.go b/vendor/github.com/stretchr/testify/assert/doc.go index c9dccc4d..4953981d 100644 --- a/vendor/github.com/stretchr/testify/assert/doc.go +++ b/vendor/github.com/stretchr/testify/assert/doc.go @@ -1,39 +1,40 @@ // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. // -// Example Usage +// # Example Usage // // The following is a complete example using assert in a standard test function: -// import ( -// "testing" -// "github.com/stretchr/testify/assert" -// ) // -// func TestSomething(t *testing.T) { +// import ( +// "testing" +// "github.com/stretchr/testify/assert" +// ) // -// var a string = "Hello" -// var b string = "Hello" +// func TestSomething(t *testing.T) { // -// assert.Equal(t, a, b, "The two words should be the same.") +// var a string = "Hello" +// var b string = "Hello" // -// } +// assert.Equal(t, a, b, "The two words should be the same.") +// +// } // // if you assert many times, use the format below: // -// import ( -// "testing" -// "github.com/stretchr/testify/assert" -// ) +// import ( +// "testing" +// "github.com/stretchr/testify/assert" +// ) // -// func TestSomething(t *testing.T) { -// assert := assert.New(t) +// func TestSomething(t *testing.T) { +// assert := assert.New(t) // -// var a string = "Hello" -// var b string = "Hello" +// var a string = "Hello" +// var b string = "Hello" // -// assert.Equal(a, b, "The two words should be the same.") -// } +// assert.Equal(a, b, "The two words should be the same.") +// } // -// Assertions +// # Assertions // // Assertions allow you to easily write test code, and are global funcs in the `assert` package. // All assertion functions take, as the first argument, the `*testing.T` object provided by the diff --git a/vendor/github.com/stretchr/testify/assert/http_assertions.go b/vendor/github.com/stretchr/testify/assert/http_assertions.go index 4ed341dd..d8038c28 100644 --- a/vendor/github.com/stretchr/testify/assert/http_assertions.go +++ b/vendor/github.com/stretchr/testify/assert/http_assertions.go @@ -23,7 +23,7 @@ func httpCode(handler http.HandlerFunc, method, url string, values url.Values) ( // HTTPSuccess asserts that a specified handler returns a success status code. // -// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) +// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) // // Returns whether the assertion was successful (true) or not (false). func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { @@ -45,7 +45,7 @@ func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, value // HTTPRedirect asserts that a specified handler returns a redirect status code. // -// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { @@ -67,7 +67,7 @@ func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, valu // HTTPError asserts that a specified handler returns an error status code. // -// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { @@ -89,7 +89,7 @@ func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values // HTTPStatusCode asserts that a specified handler returns a specified status code. // -// assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501) +// assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501) // // Returns whether the assertion was successful (true) or not (false). func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool { @@ -124,7 +124,7 @@ func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) s // HTTPBodyContains asserts that a specified handler returns a // body that contains a string. // -// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { @@ -144,7 +144,7 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, // HTTPBodyNotContains asserts that a specified handler returns a // body that does not contain a string. // -// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { diff --git a/vendor/github.com/stretchr/testify/require/doc.go b/vendor/github.com/stretchr/testify/require/doc.go index 169de392..96843472 100644 --- a/vendor/github.com/stretchr/testify/require/doc.go +++ b/vendor/github.com/stretchr/testify/require/doc.go @@ -1,24 +1,25 @@ // Package require implements the same assertions as the `assert` package but // stops test execution when a test fails. // -// Example Usage +// # Example Usage // // The following is a complete example using require in a standard test function: -// import ( -// "testing" -// "github.com/stretchr/testify/require" -// ) // -// func TestSomething(t *testing.T) { +// import ( +// "testing" +// "github.com/stretchr/testify/require" +// ) // -// var a string = "Hello" -// var b string = "Hello" +// func TestSomething(t *testing.T) { // -// require.Equal(t, a, b, "The two words should be the same.") +// var a string = "Hello" +// var b string = "Hello" // -// } +// require.Equal(t, a, b, "The two words should be the same.") // -// Assertions +// } +// +// # Assertions // // The `require` package have same global functions as in the `assert` package, // but instead of returning a boolean result they call `t.FailNow()`. diff --git a/vendor/github.com/stretchr/testify/require/require.go b/vendor/github.com/stretchr/testify/require/require.go index 59c48277..63f85214 100644 --- a/vendor/github.com/stretchr/testify/require/require.go +++ b/vendor/github.com/stretchr/testify/require/require.go @@ -37,9 +37,9 @@ func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interfac // Contains asserts that the specified string, list(array, slice...) or map contains the // specified substring or element. // -// assert.Contains(t, "Hello World", "World") -// assert.Contains(t, ["Hello", "World"], "World") -// assert.Contains(t, {"Hello": "World"}, "Hello") +// assert.Contains(t, "Hello World", "World") +// assert.Contains(t, ["Hello", "World"], "World") +// assert.Contains(t, {"Hello": "World"}, "Hello") func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -53,9 +53,9 @@ func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...int // Containsf asserts that the specified string, list(array, slice...) or map contains the // specified substring or element. // -// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") -// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") -// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") +// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") +// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") +// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -123,7 +123,7 @@ func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either // a slice or a channel with len == 0. // -// assert.Empty(t, obj) +// assert.Empty(t, obj) func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -137,7 +137,7 @@ func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) { // Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either // a slice or a channel with len == 0. // -// assert.Emptyf(t, obj, "error message %s", "formatted") +// assert.Emptyf(t, obj, "error message %s", "formatted") func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -150,7 +150,7 @@ func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) { // Equal asserts that two objects are equal. // -// assert.Equal(t, 123, 123) +// assert.Equal(t, 123, 123) // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). Function equality @@ -168,8 +168,8 @@ func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...i // EqualError asserts that a function returned an error (i.e. not `nil`) // and that it is equal to the provided error. // -// actualObj, err := SomeFunction() -// assert.EqualError(t, err, expectedErrorString) +// actualObj, err := SomeFunction() +// assert.EqualError(t, err, expectedErrorString) func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -183,8 +183,8 @@ func EqualError(t TestingT, theError error, errString string, msgAndArgs ...inte // EqualErrorf asserts that a function returned an error (i.e. not `nil`) // and that it is equal to the provided error. // -// actualObj, err := SomeFunction() -// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") +// actualObj, err := SomeFunction() +// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -195,10 +195,50 @@ func EqualErrorf(t TestingT, theError error, errString string, msg string, args t.FailNow() } +// EqualExportedValues asserts that the types of two objects are equal and their public +// fields are also equal. This is useful for comparing structs that have private fields +// that could potentially differ. +// +// type S struct { +// Exported int +// notExported int +// } +// assert.EqualExportedValues(t, S{1, 2}, S{1, 3}) => true +// assert.EqualExportedValues(t, S{1, 2}, S{2, 3}) => false +func EqualExportedValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.EqualExportedValues(t, expected, actual, msgAndArgs...) { + return + } + t.FailNow() +} + +// EqualExportedValuesf asserts that the types of two objects are equal and their public +// fields are also equal. This is useful for comparing structs that have private fields +// that could potentially differ. +// +// type S struct { +// Exported int +// notExported int +// } +// assert.EqualExportedValuesf(t, S{1, 2}, S{1, 3}, "error message %s", "formatted") => true +// assert.EqualExportedValuesf(t, S{1, 2}, S{2, 3}, "error message %s", "formatted") => false +func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.EqualExportedValuesf(t, expected, actual, msg, args...) { + return + } + t.FailNow() +} + // EqualValues asserts that two objects are equal or convertable to the same types // and equal. // -// assert.EqualValues(t, uint32(123), int32(123)) +// assert.EqualValues(t, uint32(123), int32(123)) func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -212,7 +252,7 @@ func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArg // EqualValuesf asserts that two objects are equal or convertable to the same types // and equal. // -// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted") +// assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted") func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -225,7 +265,7 @@ func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg stri // Equalf asserts that two objects are equal. // -// assert.Equalf(t, 123, 123, "error message %s", "formatted") +// assert.Equalf(t, 123, 123, "error message %s", "formatted") // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). Function equality @@ -242,10 +282,10 @@ func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, ar // Error asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if assert.Error(t, err) { -// assert.Equal(t, expectedError, err) -// } +// actualObj, err := SomeFunction() +// if assert.Error(t, err) { +// assert.Equal(t, expectedError, err) +// } func Error(t TestingT, err error, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -283,8 +323,8 @@ func ErrorAsf(t TestingT, err error, target interface{}, msg string, args ...int // ErrorContains asserts that a function returned an error (i.e. not `nil`) // and that the error contains the specified substring. // -// actualObj, err := SomeFunction() -// assert.ErrorContains(t, err, expectedErrorSubString) +// actualObj, err := SomeFunction() +// assert.ErrorContains(t, err, expectedErrorSubString) func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -298,8 +338,8 @@ func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...in // ErrorContainsf asserts that a function returned an error (i.e. not `nil`) // and that the error contains the specified substring. // -// actualObj, err := SomeFunction() -// assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted") +// actualObj, err := SomeFunction() +// assert.ErrorContainsf(t, err, expectedErrorSubString, "error message %s", "formatted") func ErrorContainsf(t TestingT, theError error, contains string, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -336,10 +376,10 @@ func ErrorIsf(t TestingT, err error, target error, msg string, args ...interface // Errorf asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if assert.Errorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } +// actualObj, err := SomeFunction() +// if assert.Errorf(t, err, "error message %s", "formatted") { +// assert.Equal(t, expectedErrorf, err) +// } func Errorf(t TestingT, err error, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -353,7 +393,7 @@ func Errorf(t TestingT, err error, msg string, args ...interface{}) { // Eventually asserts that given condition will be met in waitFor time, // periodically checking target function each tick. // -// assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond) +// assert.Eventually(t, func() bool { return true; }, time.Second, 10*time.Millisecond) func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -364,10 +404,66 @@ func Eventually(t TestingT, condition func() bool, waitFor time.Duration, tick t t.FailNow() } +// EventuallyWithT asserts that given condition will be met in waitFor time, +// periodically checking target function each tick. In contrast to Eventually, +// it supplies a CollectT to the condition function, so that the condition +// function can use the CollectT to call other assertions. +// The condition is considered "met" if no errors are raised in a tick. +// The supplied CollectT collects all errors from one tick (if there are any). +// If the condition is not met before waitFor, the collected errors of +// the last tick are copied to t. +// +// externalValue := false +// go func() { +// time.Sleep(8*time.Second) +// externalValue = true +// }() +// assert.EventuallyWithT(t, func(c *assert.CollectT) { +// // add assertions as needed; any assertion failure will fail the current tick +// assert.True(c, externalValue, "expected 'externalValue' to be true") +// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +func EventuallyWithT(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.EventuallyWithT(t, condition, waitFor, tick, msgAndArgs...) { + return + } + t.FailNow() +} + +// EventuallyWithTf asserts that given condition will be met in waitFor time, +// periodically checking target function each tick. In contrast to Eventually, +// it supplies a CollectT to the condition function, so that the condition +// function can use the CollectT to call other assertions. +// The condition is considered "met" if no errors are raised in a tick. +// The supplied CollectT collects all errors from one tick (if there are any). +// If the condition is not met before waitFor, the collected errors of +// the last tick are copied to t. +// +// externalValue := false +// go func() { +// time.Sleep(8*time.Second) +// externalValue = true +// }() +// assert.EventuallyWithTf(t, func(c *assert.CollectT, "error message %s", "formatted") { +// // add assertions as needed; any assertion failure will fail the current tick +// assert.True(c, externalValue, "expected 'externalValue' to be true") +// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +func EventuallyWithTf(t TestingT, condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.EventuallyWithTf(t, condition, waitFor, tick, msg, args...) { + return + } + t.FailNow() +} + // Eventuallyf asserts that given condition will be met in waitFor time, // periodically checking target function each tick. // -// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") +// assert.Eventuallyf(t, func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -380,7 +476,7 @@ func Eventuallyf(t TestingT, condition func() bool, waitFor time.Duration, tick // Exactly asserts that two objects are equal in value and type. // -// assert.Exactly(t, int32(123), int64(123)) +// assert.Exactly(t, int32(123), int64(123)) func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -393,7 +489,7 @@ func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs .. // Exactlyf asserts that two objects are equal in value and type. // -// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted") +// assert.Exactlyf(t, int32(123), int64(123), "error message %s", "formatted") func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -450,7 +546,7 @@ func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) { // False asserts that the specified value is false. // -// assert.False(t, myBool) +// assert.False(t, myBool) func False(t TestingT, value bool, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -463,7 +559,7 @@ func False(t TestingT, value bool, msgAndArgs ...interface{}) { // Falsef asserts that the specified value is false. // -// assert.Falsef(t, myBool, "error message %s", "formatted") +// assert.Falsef(t, myBool, "error message %s", "formatted") func Falsef(t TestingT, value bool, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -500,9 +596,9 @@ func FileExistsf(t TestingT, path string, msg string, args ...interface{}) { // Greater asserts that the first element is greater than the second // -// assert.Greater(t, 2, 1) -// assert.Greater(t, float64(2), float64(1)) -// assert.Greater(t, "b", "a") +// assert.Greater(t, 2, 1) +// assert.Greater(t, float64(2), float64(1)) +// assert.Greater(t, "b", "a") func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -515,10 +611,10 @@ func Greater(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface // GreaterOrEqual asserts that the first element is greater than or equal to the second // -// assert.GreaterOrEqual(t, 2, 1) -// assert.GreaterOrEqual(t, 2, 2) -// assert.GreaterOrEqual(t, "b", "a") -// assert.GreaterOrEqual(t, "b", "b") +// assert.GreaterOrEqual(t, 2, 1) +// assert.GreaterOrEqual(t, 2, 2) +// assert.GreaterOrEqual(t, "b", "a") +// assert.GreaterOrEqual(t, "b", "b") func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -531,10 +627,10 @@ func GreaterOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...in // GreaterOrEqualf asserts that the first element is greater than or equal to the second // -// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted") -// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted") -// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted") -// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted") +// assert.GreaterOrEqualf(t, 2, 1, "error message %s", "formatted") +// assert.GreaterOrEqualf(t, 2, 2, "error message %s", "formatted") +// assert.GreaterOrEqualf(t, "b", "a", "error message %s", "formatted") +// assert.GreaterOrEqualf(t, "b", "b", "error message %s", "formatted") func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -547,9 +643,9 @@ func GreaterOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, arg // Greaterf asserts that the first element is greater than the second // -// assert.Greaterf(t, 2, 1, "error message %s", "formatted") -// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted") -// assert.Greaterf(t, "b", "a", "error message %s", "formatted") +// assert.Greaterf(t, 2, 1, "error message %s", "formatted") +// assert.Greaterf(t, float64(2), float64(1), "error message %s", "formatted") +// assert.Greaterf(t, "b", "a", "error message %s", "formatted") func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -563,7 +659,7 @@ func Greaterf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...in // HTTPBodyContains asserts that a specified handler returns a // body that contains a string. // -// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { @@ -579,7 +675,7 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url s // HTTPBodyContainsf asserts that a specified handler returns a // body that contains a string. // -// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { @@ -595,7 +691,7 @@ func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url // HTTPBodyNotContains asserts that a specified handler returns a // body that does not contain a string. // -// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { @@ -611,7 +707,7 @@ func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, ur // HTTPBodyNotContainsf asserts that a specified handler returns a // body that does not contain a string. // -// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { @@ -626,7 +722,7 @@ func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, u // HTTPError asserts that a specified handler returns an error status code. // -// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { @@ -641,7 +737,7 @@ func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, // HTTPErrorf asserts that a specified handler returns an error status code. // -// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { @@ -656,7 +752,7 @@ func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, // HTTPRedirect asserts that a specified handler returns a redirect status code. // -// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { @@ -671,7 +767,7 @@ func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url strin // HTTPRedirectf asserts that a specified handler returns a redirect status code. // -// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { @@ -686,7 +782,7 @@ func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url stri // HTTPStatusCode asserts that a specified handler returns a specified status code. // -// assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501) +// assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501) // // Returns whether the assertion was successful (true) or not (false). func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) { @@ -701,7 +797,7 @@ func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method string, url str // HTTPStatusCodef asserts that a specified handler returns a specified status code. // -// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") +// assert.HTTPStatusCodef(t, myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) { @@ -716,7 +812,7 @@ func HTTPStatusCodef(t TestingT, handler http.HandlerFunc, method string, url st // HTTPSuccess asserts that a specified handler returns a success status code. // -// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) +// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) // // Returns whether the assertion was successful (true) or not (false). func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { @@ -731,7 +827,7 @@ func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string // HTTPSuccessf asserts that a specified handler returns a success status code. // -// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") +// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { @@ -746,7 +842,7 @@ func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url strin // Implements asserts that an object is implemented by the specified interface. // -// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) +// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -759,7 +855,7 @@ func Implements(t TestingT, interfaceObject interface{}, object interface{}, msg // Implementsf asserts that an object is implemented by the specified interface. // -// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted") +// assert.Implementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted") func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -772,7 +868,7 @@ func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, ms // InDelta asserts that the two numerals are within delta of each other. // -// assert.InDelta(t, math.Pi, 22/7.0, 0.01) +// assert.InDelta(t, math.Pi, 22/7.0, 0.01) func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -829,7 +925,7 @@ func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta f // InDeltaf asserts that the two numerals are within delta of each other. // -// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted") +// assert.InDeltaf(t, math.Pi, 22/7.0, 0.01, "error message %s", "formatted") func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -886,9 +982,9 @@ func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon fl // IsDecreasing asserts that the collection is decreasing // -// assert.IsDecreasing(t, []int{2, 1, 0}) -// assert.IsDecreasing(t, []float{2, 1}) -// assert.IsDecreasing(t, []string{"b", "a"}) +// assert.IsDecreasing(t, []int{2, 1, 0}) +// assert.IsDecreasing(t, []float{2, 1}) +// assert.IsDecreasing(t, []string{"b", "a"}) func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -901,9 +997,9 @@ func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) { // IsDecreasingf asserts that the collection is decreasing // -// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted") -// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted") -// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted") +// assert.IsDecreasingf(t, []int{2, 1, 0}, "error message %s", "formatted") +// assert.IsDecreasingf(t, []float{2, 1}, "error message %s", "formatted") +// assert.IsDecreasingf(t, []string{"b", "a"}, "error message %s", "formatted") func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -916,9 +1012,9 @@ func IsDecreasingf(t TestingT, object interface{}, msg string, args ...interface // IsIncreasing asserts that the collection is increasing // -// assert.IsIncreasing(t, []int{1, 2, 3}) -// assert.IsIncreasing(t, []float{1, 2}) -// assert.IsIncreasing(t, []string{"a", "b"}) +// assert.IsIncreasing(t, []int{1, 2, 3}) +// assert.IsIncreasing(t, []float{1, 2}) +// assert.IsIncreasing(t, []string{"a", "b"}) func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -931,9 +1027,9 @@ func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) { // IsIncreasingf asserts that the collection is increasing // -// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted") -// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted") -// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted") +// assert.IsIncreasingf(t, []int{1, 2, 3}, "error message %s", "formatted") +// assert.IsIncreasingf(t, []float{1, 2}, "error message %s", "formatted") +// assert.IsIncreasingf(t, []string{"a", "b"}, "error message %s", "formatted") func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -946,9 +1042,9 @@ func IsIncreasingf(t TestingT, object interface{}, msg string, args ...interface // IsNonDecreasing asserts that the collection is not decreasing // -// assert.IsNonDecreasing(t, []int{1, 1, 2}) -// assert.IsNonDecreasing(t, []float{1, 2}) -// assert.IsNonDecreasing(t, []string{"a", "b"}) +// assert.IsNonDecreasing(t, []int{1, 1, 2}) +// assert.IsNonDecreasing(t, []float{1, 2}) +// assert.IsNonDecreasing(t, []string{"a", "b"}) func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -961,9 +1057,9 @@ func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) // IsNonDecreasingf asserts that the collection is not decreasing // -// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted") -// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted") -// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted") +// assert.IsNonDecreasingf(t, []int{1, 1, 2}, "error message %s", "formatted") +// assert.IsNonDecreasingf(t, []float{1, 2}, "error message %s", "formatted") +// assert.IsNonDecreasingf(t, []string{"a", "b"}, "error message %s", "formatted") func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -976,9 +1072,9 @@ func IsNonDecreasingf(t TestingT, object interface{}, msg string, args ...interf // IsNonIncreasing asserts that the collection is not increasing // -// assert.IsNonIncreasing(t, []int{2, 1, 1}) -// assert.IsNonIncreasing(t, []float{2, 1}) -// assert.IsNonIncreasing(t, []string{"b", "a"}) +// assert.IsNonIncreasing(t, []int{2, 1, 1}) +// assert.IsNonIncreasing(t, []float{2, 1}) +// assert.IsNonIncreasing(t, []string{"b", "a"}) func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -991,9 +1087,9 @@ func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) // IsNonIncreasingf asserts that the collection is not increasing // -// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted") -// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted") -// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted") +// assert.IsNonIncreasingf(t, []int{2, 1, 1}, "error message %s", "formatted") +// assert.IsNonIncreasingf(t, []float{2, 1}, "error message %s", "formatted") +// assert.IsNonIncreasingf(t, []string{"b", "a"}, "error message %s", "formatted") func IsNonIncreasingf(t TestingT, object interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1028,7 +1124,7 @@ func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg strin // JSONEq asserts that two JSON strings are equivalent. // -// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) +// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1041,7 +1137,7 @@ func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{ // JSONEqf asserts that two JSON strings are equivalent. // -// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") +// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1055,7 +1151,7 @@ func JSONEqf(t TestingT, expected string, actual string, msg string, args ...int // Len asserts that the specified object has specific length. // Len also fails if the object has a type that len() not accept. // -// assert.Len(t, mySlice, 3) +// assert.Len(t, mySlice, 3) func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1069,7 +1165,7 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) // Lenf asserts that the specified object has specific length. // Lenf also fails if the object has a type that len() not accept. // -// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") +// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1082,9 +1178,9 @@ func Lenf(t TestingT, object interface{}, length int, msg string, args ...interf // Less asserts that the first element is less than the second // -// assert.Less(t, 1, 2) -// assert.Less(t, float64(1), float64(2)) -// assert.Less(t, "a", "b") +// assert.Less(t, 1, 2) +// assert.Less(t, float64(1), float64(2)) +// assert.Less(t, "a", "b") func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1097,10 +1193,10 @@ func Less(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) // LessOrEqual asserts that the first element is less than or equal to the second // -// assert.LessOrEqual(t, 1, 2) -// assert.LessOrEqual(t, 2, 2) -// assert.LessOrEqual(t, "a", "b") -// assert.LessOrEqual(t, "b", "b") +// assert.LessOrEqual(t, 1, 2) +// assert.LessOrEqual(t, 2, 2) +// assert.LessOrEqual(t, "a", "b") +// assert.LessOrEqual(t, "b", "b") func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1113,10 +1209,10 @@ func LessOrEqual(t TestingT, e1 interface{}, e2 interface{}, msgAndArgs ...inter // LessOrEqualf asserts that the first element is less than or equal to the second // -// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted") -// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted") -// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted") -// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted") +// assert.LessOrEqualf(t, 1, 2, "error message %s", "formatted") +// assert.LessOrEqualf(t, 2, 2, "error message %s", "formatted") +// assert.LessOrEqualf(t, "a", "b", "error message %s", "formatted") +// assert.LessOrEqualf(t, "b", "b", "error message %s", "formatted") func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1129,9 +1225,9 @@ func LessOrEqualf(t TestingT, e1 interface{}, e2 interface{}, msg string, args . // Lessf asserts that the first element is less than the second // -// assert.Lessf(t, 1, 2, "error message %s", "formatted") -// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted") -// assert.Lessf(t, "a", "b", "error message %s", "formatted") +// assert.Lessf(t, 1, 2, "error message %s", "formatted") +// assert.Lessf(t, float64(1), float64(2), "error message %s", "formatted") +// assert.Lessf(t, "a", "b", "error message %s", "formatted") func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1144,8 +1240,8 @@ func Lessf(t TestingT, e1 interface{}, e2 interface{}, msg string, args ...inter // Negative asserts that the specified element is negative // -// assert.Negative(t, -1) -// assert.Negative(t, -1.23) +// assert.Negative(t, -1) +// assert.Negative(t, -1.23) func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1158,8 +1254,8 @@ func Negative(t TestingT, e interface{}, msgAndArgs ...interface{}) { // Negativef asserts that the specified element is negative // -// assert.Negativef(t, -1, "error message %s", "formatted") -// assert.Negativef(t, -1.23, "error message %s", "formatted") +// assert.Negativef(t, -1, "error message %s", "formatted") +// assert.Negativef(t, -1.23, "error message %s", "formatted") func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1173,7 +1269,7 @@ func Negativef(t TestingT, e interface{}, msg string, args ...interface{}) { // Never asserts that the given condition doesn't satisfy in waitFor time, // periodically checking the target function each tick. // -// assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond) +// assert.Never(t, func() bool { return false; }, time.Second, 10*time.Millisecond) func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1187,7 +1283,7 @@ func Never(t TestingT, condition func() bool, waitFor time.Duration, tick time.D // Neverf asserts that the given condition doesn't satisfy in waitFor time, // periodically checking the target function each tick. // -// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") +// assert.Neverf(t, func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1200,7 +1296,7 @@ func Neverf(t TestingT, condition func() bool, waitFor time.Duration, tick time. // Nil asserts that the specified object is nil. // -// assert.Nil(t, err) +// assert.Nil(t, err) func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1213,7 +1309,7 @@ func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) { // Nilf asserts that the specified object is nil. // -// assert.Nilf(t, err, "error message %s", "formatted") +// assert.Nilf(t, err, "error message %s", "formatted") func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1250,10 +1346,10 @@ func NoDirExistsf(t TestingT, path string, msg string, args ...interface{}) { // NoError asserts that a function returned no error (i.e. `nil`). // -// actualObj, err := SomeFunction() -// if assert.NoError(t, err) { -// assert.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// if assert.NoError(t, err) { +// assert.Equal(t, expectedObj, actualObj) +// } func NoError(t TestingT, err error, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1266,10 +1362,10 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) { // NoErrorf asserts that a function returned no error (i.e. `nil`). // -// actualObj, err := SomeFunction() -// if assert.NoErrorf(t, err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// if assert.NoErrorf(t, err, "error message %s", "formatted") { +// assert.Equal(t, expectedObj, actualObj) +// } func NoErrorf(t TestingT, err error, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1307,9 +1403,9 @@ func NoFileExistsf(t TestingT, path string, msg string, args ...interface{}) { // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // -// assert.NotContains(t, "Hello World", "Earth") -// assert.NotContains(t, ["Hello", "World"], "Earth") -// assert.NotContains(t, {"Hello": "World"}, "Earth") +// assert.NotContains(t, "Hello World", "Earth") +// assert.NotContains(t, ["Hello", "World"], "Earth") +// assert.NotContains(t, {"Hello": "World"}, "Earth") func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1323,9 +1419,9 @@ func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ... // NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // -// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") -// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") -// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") +// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") +// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") +// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1339,9 +1435,9 @@ func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, a // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // -// if assert.NotEmpty(t, obj) { -// assert.Equal(t, "two", obj[1]) -// } +// if assert.NotEmpty(t, obj) { +// assert.Equal(t, "two", obj[1]) +// } func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1355,9 +1451,9 @@ func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) { // NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // -// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } +// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { +// assert.Equal(t, "two", obj[1]) +// } func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1370,7 +1466,7 @@ func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) // NotEqual asserts that the specified values are NOT equal. // -// assert.NotEqual(t, obj1, obj2) +// assert.NotEqual(t, obj1, obj2) // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). @@ -1386,7 +1482,7 @@ func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs . // NotEqualValues asserts that two objects are not equal even when converted to the same type // -// assert.NotEqualValues(t, obj1, obj2) +// assert.NotEqualValues(t, obj1, obj2) func NotEqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1399,7 +1495,7 @@ func NotEqualValues(t TestingT, expected interface{}, actual interface{}, msgAnd // NotEqualValuesf asserts that two objects are not equal even when converted to the same type // -// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted") +// assert.NotEqualValuesf(t, obj1, obj2, "error message %s", "formatted") func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1412,7 +1508,7 @@ func NotEqualValuesf(t TestingT, expected interface{}, actual interface{}, msg s // NotEqualf asserts that the specified values are NOT equal. // -// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") +// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). @@ -1452,7 +1548,7 @@ func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interf // NotNil asserts that the specified object is not nil. // -// assert.NotNil(t, err) +// assert.NotNil(t, err) func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1465,7 +1561,7 @@ func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) { // NotNilf asserts that the specified object is not nil. // -// assert.NotNilf(t, err, "error message %s", "formatted") +// assert.NotNilf(t, err, "error message %s", "formatted") func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1478,7 +1574,7 @@ func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) { // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. // -// assert.NotPanics(t, func(){ RemainCalm() }) +// assert.NotPanics(t, func(){ RemainCalm() }) func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1491,7 +1587,7 @@ func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { // NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. // -// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") +// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1504,8 +1600,8 @@ func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interfac // NotRegexp asserts that a specified regexp does not match a string. // -// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") -// assert.NotRegexp(t, "^start", "it's not starting") +// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") +// assert.NotRegexp(t, "^start", "it's not starting") func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1518,8 +1614,8 @@ func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interf // NotRegexpf asserts that a specified regexp does not match a string. // -// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") -// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") +// assert.NotRegexpf(t, regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") +// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1532,7 +1628,7 @@ func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args .. // NotSame asserts that two pointers do not reference the same object. // -// assert.NotSame(t, ptr1, ptr2) +// assert.NotSame(t, ptr1, ptr2) // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1548,7 +1644,7 @@ func NotSame(t TestingT, expected interface{}, actual interface{}, msgAndArgs .. // NotSamef asserts that two pointers do not reference the same object. // -// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted") +// assert.NotSamef(t, ptr1, ptr2, "error message %s", "formatted") // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1565,7 +1661,7 @@ func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, // NotSubset asserts that the specified list(array, slice...) contains not all // elements given in the specified subset(array, slice...). // -// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1579,7 +1675,7 @@ func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...i // NotSubsetf asserts that the specified list(array, slice...) contains not all // elements given in the specified subset(array, slice...). // -// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1614,7 +1710,7 @@ func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) { // Panics asserts that the code inside the specified PanicTestFunc panics. // -// assert.Panics(t, func(){ GoCrazy() }) +// assert.Panics(t, func(){ GoCrazy() }) func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1629,7 +1725,7 @@ func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { // panics, and that the recovered panic value is an error that satisfies the // EqualError comparison. // -// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() }) +// assert.PanicsWithError(t, "crazy error", func(){ GoCrazy() }) func PanicsWithError(t TestingT, errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1644,7 +1740,7 @@ func PanicsWithError(t TestingT, errString string, f assert.PanicTestFunc, msgAn // panics, and that the recovered panic value is an error that satisfies the // EqualError comparison. // -// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +// assert.PanicsWithErrorf(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") func PanicsWithErrorf(t TestingT, errString string, f assert.PanicTestFunc, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1658,7 +1754,7 @@ func PanicsWithErrorf(t TestingT, errString string, f assert.PanicTestFunc, msg // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that // the recovered panic value equals the expected panic value. // -// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) +// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1672,7 +1768,7 @@ func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, m // PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that // the recovered panic value equals the expected panic value. // -// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1685,7 +1781,7 @@ func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, // Panicsf asserts that the code inside the specified PanicTestFunc panics. // -// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") +// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1698,8 +1794,8 @@ func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{} // Positive asserts that the specified element is positive // -// assert.Positive(t, 1) -// assert.Positive(t, 1.23) +// assert.Positive(t, 1) +// assert.Positive(t, 1.23) func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1712,8 +1808,8 @@ func Positive(t TestingT, e interface{}, msgAndArgs ...interface{}) { // Positivef asserts that the specified element is positive // -// assert.Positivef(t, 1, "error message %s", "formatted") -// assert.Positivef(t, 1.23, "error message %s", "formatted") +// assert.Positivef(t, 1, "error message %s", "formatted") +// assert.Positivef(t, 1.23, "error message %s", "formatted") func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1726,8 +1822,8 @@ func Positivef(t TestingT, e interface{}, msg string, args ...interface{}) { // Regexp asserts that a specified regexp matches a string. // -// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") -// assert.Regexp(t, "start...$", "it's not starting") +// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") +// assert.Regexp(t, "start...$", "it's not starting") func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1740,8 +1836,8 @@ func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface // Regexpf asserts that a specified regexp matches a string. // -// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") -// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") +// assert.Regexpf(t, regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") +// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1754,7 +1850,7 @@ func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...in // Same asserts that two pointers reference the same object. // -// assert.Same(t, ptr1, ptr2) +// assert.Same(t, ptr1, ptr2) // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1770,7 +1866,7 @@ func Same(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...in // Samef asserts that two pointers reference the same object. // -// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted") +// assert.Samef(t, ptr1, ptr2, "error message %s", "formatted") // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1787,7 +1883,7 @@ func Samef(t TestingT, expected interface{}, actual interface{}, msg string, arg // Subset asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // -// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1801,7 +1897,7 @@ func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...inte // Subsetf asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // -// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1814,7 +1910,7 @@ func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args // True asserts that the specified value is true. // -// assert.True(t, myBool) +// assert.True(t, myBool) func True(t TestingT, value bool, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1827,7 +1923,7 @@ func True(t TestingT, value bool, msgAndArgs ...interface{}) { // Truef asserts that the specified value is true. // -// assert.Truef(t, myBool, "error message %s", "formatted") +// assert.Truef(t, myBool, "error message %s", "formatted") func Truef(t TestingT, value bool, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1840,7 +1936,7 @@ func Truef(t TestingT, value bool, msg string, args ...interface{}) { // WithinDuration asserts that the two times are within duration delta of each other. // -// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) +// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1853,7 +1949,7 @@ func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time // WithinDurationf asserts that the two times are within duration delta of each other. // -// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") +// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1864,6 +1960,32 @@ func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta tim t.FailNow() } +// WithinRange asserts that a time is within a time range (inclusive). +// +// assert.WithinRange(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second)) +func WithinRange(t TestingT, actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.WithinRange(t, actual, start, end, msgAndArgs...) { + return + } + t.FailNow() +} + +// WithinRangef asserts that a time is within a time range (inclusive). +// +// assert.WithinRangef(t, time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted") +func WithinRangef(t TestingT, actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.WithinRangef(t, actual, start, end, msg, args...) { + return + } + t.FailNow() +} + // YAMLEq asserts that two YAML strings are equivalent. func YAMLEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go b/vendor/github.com/stretchr/testify/require/require_forward.go index 5bb07c89..3b5b0933 100644 --- a/vendor/github.com/stretchr/testify/require/require_forward.go +++ b/vendor/github.com/stretchr/testify/require/require_forward.go @@ -31,9 +31,9 @@ func (a *Assertions) Conditionf(comp assert.Comparison, msg string, args ...inte // Contains asserts that the specified string, list(array, slice...) or map contains the // specified substring or element. // -// a.Contains("Hello World", "World") -// a.Contains(["Hello", "World"], "World") -// a.Contains({"Hello": "World"}, "Hello") +// a.Contains("Hello World", "World") +// a.Contains(["Hello", "World"], "World") +// a.Contains({"Hello": "World"}, "Hello") func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -44,9 +44,9 @@ func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs .. // Containsf asserts that the specified string, list(array, slice...) or map contains the // specified substring or element. // -// a.Containsf("Hello World", "World", "error message %s", "formatted") -// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted") -// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted") +// a.Containsf("Hello World", "World", "error message %s", "formatted") +// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted") +// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted") func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -99,7 +99,7 @@ func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg st // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either // a slice or a channel with len == 0. // -// a.Empty(obj) +// a.Empty(obj) func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -110,7 +110,7 @@ func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) { // Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either // a slice or a channel with len == 0. // -// a.Emptyf(obj, "error message %s", "formatted") +// a.Emptyf(obj, "error message %s", "formatted") func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -120,7 +120,7 @@ func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) // Equal asserts that two objects are equal. // -// a.Equal(123, 123) +// a.Equal(123, 123) // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). Function equality @@ -135,8 +135,8 @@ func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs // EqualError asserts that a function returned an error (i.e. not `nil`) // and that it is equal to the provided error. // -// actualObj, err := SomeFunction() -// a.EqualError(err, expectedErrorString) +// actualObj, err := SomeFunction() +// a.EqualError(err, expectedErrorString) func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -147,8 +147,8 @@ func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ... // EqualErrorf asserts that a function returned an error (i.e. not `nil`) // and that it is equal to the provided error. // -// actualObj, err := SomeFunction() -// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted") +// actualObj, err := SomeFunction() +// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted") func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -156,10 +156,44 @@ func (a *Assertions) EqualErrorf(theError error, errString string, msg string, a EqualErrorf(a.t, theError, errString, msg, args...) } +// EqualExportedValues asserts that the types of two objects are equal and their public +// fields are also equal. This is useful for comparing structs that have private fields +// that could potentially differ. +// +// type S struct { +// Exported int +// notExported int +// } +// a.EqualExportedValues(S{1, 2}, S{1, 3}) => true +// a.EqualExportedValues(S{1, 2}, S{2, 3}) => false +func (a *Assertions) EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + EqualExportedValues(a.t, expected, actual, msgAndArgs...) +} + +// EqualExportedValuesf asserts that the types of two objects are equal and their public +// fields are also equal. This is useful for comparing structs that have private fields +// that could potentially differ. +// +// type S struct { +// Exported int +// notExported int +// } +// a.EqualExportedValuesf(S{1, 2}, S{1, 3}, "error message %s", "formatted") => true +// a.EqualExportedValuesf(S{1, 2}, S{2, 3}, "error message %s", "formatted") => false +func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + EqualExportedValuesf(a.t, expected, actual, msg, args...) +} + // EqualValues asserts that two objects are equal or convertable to the same types // and equal. // -// a.EqualValues(uint32(123), int32(123)) +// a.EqualValues(uint32(123), int32(123)) func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -170,7 +204,7 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn // EqualValuesf asserts that two objects are equal or convertable to the same types // and equal. // -// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted") +// a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted") func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -180,7 +214,7 @@ func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg // Equalf asserts that two objects are equal. // -// a.Equalf(123, 123, "error message %s", "formatted") +// a.Equalf(123, 123, "error message %s", "formatted") // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). Function equality @@ -194,10 +228,10 @@ func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string // Error asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if a.Error(err) { -// assert.Equal(t, expectedError, err) -// } +// actualObj, err := SomeFunction() +// if a.Error(err) { +// assert.Equal(t, expectedError, err) +// } func (a *Assertions) Error(err error, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -226,8 +260,8 @@ func (a *Assertions) ErrorAsf(err error, target interface{}, msg string, args .. // ErrorContains asserts that a function returned an error (i.e. not `nil`) // and that the error contains the specified substring. // -// actualObj, err := SomeFunction() -// a.ErrorContains(err, expectedErrorSubString) +// actualObj, err := SomeFunction() +// a.ErrorContains(err, expectedErrorSubString) func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -238,8 +272,8 @@ func (a *Assertions) ErrorContains(theError error, contains string, msgAndArgs . // ErrorContainsf asserts that a function returned an error (i.e. not `nil`) // and that the error contains the specified substring. // -// actualObj, err := SomeFunction() -// a.ErrorContainsf(err, expectedErrorSubString, "error message %s", "formatted") +// actualObj, err := SomeFunction() +// a.ErrorContainsf(err, expectedErrorSubString, "error message %s", "formatted") func (a *Assertions) ErrorContainsf(theError error, contains string, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -267,10 +301,10 @@ func (a *Assertions) ErrorIsf(err error, target error, msg string, args ...inter // Errorf asserts that a function returned an error (i.e. not `nil`). // -// actualObj, err := SomeFunction() -// if a.Errorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedErrorf, err) -// } +// actualObj, err := SomeFunction() +// if a.Errorf(err, "error message %s", "formatted") { +// assert.Equal(t, expectedErrorf, err) +// } func (a *Assertions) Errorf(err error, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -281,7 +315,7 @@ func (a *Assertions) Errorf(err error, msg string, args ...interface{}) { // Eventually asserts that given condition will be met in waitFor time, // periodically checking target function each tick. // -// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond) +// a.Eventually(func() bool { return true; }, time.Second, 10*time.Millisecond) func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -289,10 +323,60 @@ func (a *Assertions) Eventually(condition func() bool, waitFor time.Duration, ti Eventually(a.t, condition, waitFor, tick, msgAndArgs...) } +// EventuallyWithT asserts that given condition will be met in waitFor time, +// periodically checking target function each tick. In contrast to Eventually, +// it supplies a CollectT to the condition function, so that the condition +// function can use the CollectT to call other assertions. +// The condition is considered "met" if no errors are raised in a tick. +// The supplied CollectT collects all errors from one tick (if there are any). +// If the condition is not met before waitFor, the collected errors of +// the last tick are copied to t. +// +// externalValue := false +// go func() { +// time.Sleep(8*time.Second) +// externalValue = true +// }() +// a.EventuallyWithT(func(c *assert.CollectT) { +// // add assertions as needed; any assertion failure will fail the current tick +// assert.True(c, externalValue, "expected 'externalValue' to be true") +// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +func (a *Assertions) EventuallyWithT(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + EventuallyWithT(a.t, condition, waitFor, tick, msgAndArgs...) +} + +// EventuallyWithTf asserts that given condition will be met in waitFor time, +// periodically checking target function each tick. In contrast to Eventually, +// it supplies a CollectT to the condition function, so that the condition +// function can use the CollectT to call other assertions. +// The condition is considered "met" if no errors are raised in a tick. +// The supplied CollectT collects all errors from one tick (if there are any). +// If the condition is not met before waitFor, the collected errors of +// the last tick are copied to t. +// +// externalValue := false +// go func() { +// time.Sleep(8*time.Second) +// externalValue = true +// }() +// a.EventuallyWithTf(func(c *assert.CollectT, "error message %s", "formatted") { +// // add assertions as needed; any assertion failure will fail the current tick +// assert.True(c, externalValue, "expected 'externalValue' to be true") +// }, 1*time.Second, 10*time.Second, "external state has not changed to 'true'; still false") +func (a *Assertions) EventuallyWithTf(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + EventuallyWithTf(a.t, condition, waitFor, tick, msg, args...) +} + // Eventuallyf asserts that given condition will be met in waitFor time, // periodically checking target function each tick. // -// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") +// a.Eventuallyf(func() bool { return true; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -302,7 +386,7 @@ func (a *Assertions) Eventuallyf(condition func() bool, waitFor time.Duration, t // Exactly asserts that two objects are equal in value and type. // -// a.Exactly(int32(123), int64(123)) +// a.Exactly(int32(123), int64(123)) func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -312,7 +396,7 @@ func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArg // Exactlyf asserts that two objects are equal in value and type. // -// a.Exactlyf(int32(123), int64(123), "error message %s", "formatted") +// a.Exactlyf(int32(123), int64(123), "error message %s", "formatted") func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -354,7 +438,7 @@ func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{ // False asserts that the specified value is false. // -// a.False(myBool) +// a.False(myBool) func (a *Assertions) False(value bool, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -364,7 +448,7 @@ func (a *Assertions) False(value bool, msgAndArgs ...interface{}) { // Falsef asserts that the specified value is false. // -// a.Falsef(myBool, "error message %s", "formatted") +// a.Falsef(myBool, "error message %s", "formatted") func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -392,9 +476,9 @@ func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) { // Greater asserts that the first element is greater than the second // -// a.Greater(2, 1) -// a.Greater(float64(2), float64(1)) -// a.Greater("b", "a") +// a.Greater(2, 1) +// a.Greater(float64(2), float64(1)) +// a.Greater("b", "a") func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -404,10 +488,10 @@ func (a *Assertions) Greater(e1 interface{}, e2 interface{}, msgAndArgs ...inter // GreaterOrEqual asserts that the first element is greater than or equal to the second // -// a.GreaterOrEqual(2, 1) -// a.GreaterOrEqual(2, 2) -// a.GreaterOrEqual("b", "a") -// a.GreaterOrEqual("b", "b") +// a.GreaterOrEqual(2, 1) +// a.GreaterOrEqual(2, 2) +// a.GreaterOrEqual("b", "a") +// a.GreaterOrEqual("b", "b") func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -417,10 +501,10 @@ func (a *Assertions) GreaterOrEqual(e1 interface{}, e2 interface{}, msgAndArgs . // GreaterOrEqualf asserts that the first element is greater than or equal to the second // -// a.GreaterOrEqualf(2, 1, "error message %s", "formatted") -// a.GreaterOrEqualf(2, 2, "error message %s", "formatted") -// a.GreaterOrEqualf("b", "a", "error message %s", "formatted") -// a.GreaterOrEqualf("b", "b", "error message %s", "formatted") +// a.GreaterOrEqualf(2, 1, "error message %s", "formatted") +// a.GreaterOrEqualf(2, 2, "error message %s", "formatted") +// a.GreaterOrEqualf("b", "a", "error message %s", "formatted") +// a.GreaterOrEqualf("b", "b", "error message %s", "formatted") func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -430,9 +514,9 @@ func (a *Assertions) GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, // Greaterf asserts that the first element is greater than the second // -// a.Greaterf(2, 1, "error message %s", "formatted") -// a.Greaterf(float64(2), float64(1), "error message %s", "formatted") -// a.Greaterf("b", "a", "error message %s", "formatted") +// a.Greaterf(2, 1, "error message %s", "formatted") +// a.Greaterf(float64(2), float64(1), "error message %s", "formatted") +// a.Greaterf("b", "a", "error message %s", "formatted") func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -443,7 +527,7 @@ func (a *Assertions) Greaterf(e1 interface{}, e2 interface{}, msg string, args . // HTTPBodyContains asserts that a specified handler returns a // body that contains a string. // -// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { @@ -456,7 +540,7 @@ func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, u // HTTPBodyContainsf asserts that a specified handler returns a // body that contains a string. // -// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { @@ -469,7 +553,7 @@ func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, // HTTPBodyNotContains asserts that a specified handler returns a // body that does not contain a string. // -// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { @@ -482,7 +566,7 @@ func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string // HTTPBodyNotContainsf asserts that a specified handler returns a // body that does not contain a string. // -// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { @@ -494,7 +578,7 @@ func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method strin // HTTPError asserts that a specified handler returns an error status code. // -// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { @@ -506,7 +590,7 @@ func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url stri // HTTPErrorf asserts that a specified handler returns an error status code. // -// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { @@ -518,7 +602,7 @@ func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url str // HTTPRedirect asserts that a specified handler returns a redirect status code. // -// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { @@ -530,7 +614,7 @@ func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url s // HTTPRedirectf asserts that a specified handler returns a redirect status code. // -// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { @@ -542,7 +626,7 @@ func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url // HTTPStatusCode asserts that a specified handler returns a specified status code. // -// a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501) +// a.HTTPStatusCode(myHandler, "GET", "/notImplemented", nil, 501) // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) { @@ -554,7 +638,7 @@ func (a *Assertions) HTTPStatusCode(handler http.HandlerFunc, method string, url // HTTPStatusCodef asserts that a specified handler returns a specified status code. // -// a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") +// a.HTTPStatusCodef(myHandler, "GET", "/notImplemented", nil, 501, "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) { @@ -566,7 +650,7 @@ func (a *Assertions) HTTPStatusCodef(handler http.HandlerFunc, method string, ur // HTTPSuccess asserts that a specified handler returns a success status code. // -// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) +// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { @@ -578,7 +662,7 @@ func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url st // HTTPSuccessf asserts that a specified handler returns a success status code. // -// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") +// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") // // Returns whether the assertion was successful (true) or not (false). func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { @@ -590,7 +674,7 @@ func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url s // Implements asserts that an object is implemented by the specified interface. // -// a.Implements((*MyInterface)(nil), new(MyObject)) +// a.Implements((*MyInterface)(nil), new(MyObject)) func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -600,7 +684,7 @@ func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, // Implementsf asserts that an object is implemented by the specified interface. // -// a.Implementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted") +// a.Implementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted") func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -610,7 +694,7 @@ func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{} // InDelta asserts that the two numerals are within delta of each other. // -// a.InDelta(math.Pi, 22/7.0, 0.01) +// a.InDelta(math.Pi, 22/7.0, 0.01) func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -652,7 +736,7 @@ func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, del // InDeltaf asserts that the two numerals are within delta of each other. // -// a.InDeltaf(math.Pi, 22/7.0, 0.01, "error message %s", "formatted") +// a.InDeltaf(math.Pi, 22/7.0, 0.01, "error message %s", "formatted") func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -694,9 +778,9 @@ func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilo // IsDecreasing asserts that the collection is decreasing // -// a.IsDecreasing([]int{2, 1, 0}) -// a.IsDecreasing([]float{2, 1}) -// a.IsDecreasing([]string{"b", "a"}) +// a.IsDecreasing([]int{2, 1, 0}) +// a.IsDecreasing([]float{2, 1}) +// a.IsDecreasing([]string{"b", "a"}) func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -706,9 +790,9 @@ func (a *Assertions) IsDecreasing(object interface{}, msgAndArgs ...interface{}) // IsDecreasingf asserts that the collection is decreasing // -// a.IsDecreasingf([]int{2, 1, 0}, "error message %s", "formatted") -// a.IsDecreasingf([]float{2, 1}, "error message %s", "formatted") -// a.IsDecreasingf([]string{"b", "a"}, "error message %s", "formatted") +// a.IsDecreasingf([]int{2, 1, 0}, "error message %s", "formatted") +// a.IsDecreasingf([]float{2, 1}, "error message %s", "formatted") +// a.IsDecreasingf([]string{"b", "a"}, "error message %s", "formatted") func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -718,9 +802,9 @@ func (a *Assertions) IsDecreasingf(object interface{}, msg string, args ...inter // IsIncreasing asserts that the collection is increasing // -// a.IsIncreasing([]int{1, 2, 3}) -// a.IsIncreasing([]float{1, 2}) -// a.IsIncreasing([]string{"a", "b"}) +// a.IsIncreasing([]int{1, 2, 3}) +// a.IsIncreasing([]float{1, 2}) +// a.IsIncreasing([]string{"a", "b"}) func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -730,9 +814,9 @@ func (a *Assertions) IsIncreasing(object interface{}, msgAndArgs ...interface{}) // IsIncreasingf asserts that the collection is increasing // -// a.IsIncreasingf([]int{1, 2, 3}, "error message %s", "formatted") -// a.IsIncreasingf([]float{1, 2}, "error message %s", "formatted") -// a.IsIncreasingf([]string{"a", "b"}, "error message %s", "formatted") +// a.IsIncreasingf([]int{1, 2, 3}, "error message %s", "formatted") +// a.IsIncreasingf([]float{1, 2}, "error message %s", "formatted") +// a.IsIncreasingf([]string{"a", "b"}, "error message %s", "formatted") func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -742,9 +826,9 @@ func (a *Assertions) IsIncreasingf(object interface{}, msg string, args ...inter // IsNonDecreasing asserts that the collection is not decreasing // -// a.IsNonDecreasing([]int{1, 1, 2}) -// a.IsNonDecreasing([]float{1, 2}) -// a.IsNonDecreasing([]string{"a", "b"}) +// a.IsNonDecreasing([]int{1, 1, 2}) +// a.IsNonDecreasing([]float{1, 2}) +// a.IsNonDecreasing([]string{"a", "b"}) func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -754,9 +838,9 @@ func (a *Assertions) IsNonDecreasing(object interface{}, msgAndArgs ...interface // IsNonDecreasingf asserts that the collection is not decreasing // -// a.IsNonDecreasingf([]int{1, 1, 2}, "error message %s", "formatted") -// a.IsNonDecreasingf([]float{1, 2}, "error message %s", "formatted") -// a.IsNonDecreasingf([]string{"a", "b"}, "error message %s", "formatted") +// a.IsNonDecreasingf([]int{1, 1, 2}, "error message %s", "formatted") +// a.IsNonDecreasingf([]float{1, 2}, "error message %s", "formatted") +// a.IsNonDecreasingf([]string{"a", "b"}, "error message %s", "formatted") func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -766,9 +850,9 @@ func (a *Assertions) IsNonDecreasingf(object interface{}, msg string, args ...in // IsNonIncreasing asserts that the collection is not increasing // -// a.IsNonIncreasing([]int{2, 1, 1}) -// a.IsNonIncreasing([]float{2, 1}) -// a.IsNonIncreasing([]string{"b", "a"}) +// a.IsNonIncreasing([]int{2, 1, 1}) +// a.IsNonIncreasing([]float{2, 1}) +// a.IsNonIncreasing([]string{"b", "a"}) func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -778,9 +862,9 @@ func (a *Assertions) IsNonIncreasing(object interface{}, msgAndArgs ...interface // IsNonIncreasingf asserts that the collection is not increasing // -// a.IsNonIncreasingf([]int{2, 1, 1}, "error message %s", "formatted") -// a.IsNonIncreasingf([]float{2, 1}, "error message %s", "formatted") -// a.IsNonIncreasingf([]string{"b", "a"}, "error message %s", "formatted") +// a.IsNonIncreasingf([]int{2, 1, 1}, "error message %s", "formatted") +// a.IsNonIncreasingf([]float{2, 1}, "error message %s", "formatted") +// a.IsNonIncreasingf([]string{"b", "a"}, "error message %s", "formatted") func (a *Assertions) IsNonIncreasingf(object interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -806,7 +890,7 @@ func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg s // JSONEq asserts that two JSON strings are equivalent. // -// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) +// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -816,7 +900,7 @@ func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interf // JSONEqf asserts that two JSON strings are equivalent. // -// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") +// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -827,7 +911,7 @@ func (a *Assertions) JSONEqf(expected string, actual string, msg string, args .. // Len asserts that the specified object has specific length. // Len also fails if the object has a type that len() not accept. // -// a.Len(mySlice, 3) +// a.Len(mySlice, 3) func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -838,7 +922,7 @@ func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface // Lenf asserts that the specified object has specific length. // Lenf also fails if the object has a type that len() not accept. // -// a.Lenf(mySlice, 3, "error message %s", "formatted") +// a.Lenf(mySlice, 3, "error message %s", "formatted") func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -848,9 +932,9 @@ func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...in // Less asserts that the first element is less than the second // -// a.Less(1, 2) -// a.Less(float64(1), float64(2)) -// a.Less("a", "b") +// a.Less(1, 2) +// a.Less(float64(1), float64(2)) +// a.Less("a", "b") func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -860,10 +944,10 @@ func (a *Assertions) Less(e1 interface{}, e2 interface{}, msgAndArgs ...interfac // LessOrEqual asserts that the first element is less than or equal to the second // -// a.LessOrEqual(1, 2) -// a.LessOrEqual(2, 2) -// a.LessOrEqual("a", "b") -// a.LessOrEqual("b", "b") +// a.LessOrEqual(1, 2) +// a.LessOrEqual(2, 2) +// a.LessOrEqual("a", "b") +// a.LessOrEqual("b", "b") func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -873,10 +957,10 @@ func (a *Assertions) LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...i // LessOrEqualf asserts that the first element is less than or equal to the second // -// a.LessOrEqualf(1, 2, "error message %s", "formatted") -// a.LessOrEqualf(2, 2, "error message %s", "formatted") -// a.LessOrEqualf("a", "b", "error message %s", "formatted") -// a.LessOrEqualf("b", "b", "error message %s", "formatted") +// a.LessOrEqualf(1, 2, "error message %s", "formatted") +// a.LessOrEqualf(2, 2, "error message %s", "formatted") +// a.LessOrEqualf("a", "b", "error message %s", "formatted") +// a.LessOrEqualf("b", "b", "error message %s", "formatted") func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -886,9 +970,9 @@ func (a *Assertions) LessOrEqualf(e1 interface{}, e2 interface{}, msg string, ar // Lessf asserts that the first element is less than the second // -// a.Lessf(1, 2, "error message %s", "formatted") -// a.Lessf(float64(1), float64(2), "error message %s", "formatted") -// a.Lessf("a", "b", "error message %s", "formatted") +// a.Lessf(1, 2, "error message %s", "formatted") +// a.Lessf(float64(1), float64(2), "error message %s", "formatted") +// a.Lessf("a", "b", "error message %s", "formatted") func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -898,8 +982,8 @@ func (a *Assertions) Lessf(e1 interface{}, e2 interface{}, msg string, args ...i // Negative asserts that the specified element is negative // -// a.Negative(-1) -// a.Negative(-1.23) +// a.Negative(-1) +// a.Negative(-1.23) func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -909,8 +993,8 @@ func (a *Assertions) Negative(e interface{}, msgAndArgs ...interface{}) { // Negativef asserts that the specified element is negative // -// a.Negativef(-1, "error message %s", "formatted") -// a.Negativef(-1.23, "error message %s", "formatted") +// a.Negativef(-1, "error message %s", "formatted") +// a.Negativef(-1.23, "error message %s", "formatted") func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -921,7 +1005,7 @@ func (a *Assertions) Negativef(e interface{}, msg string, args ...interface{}) { // Never asserts that the given condition doesn't satisfy in waitFor time, // periodically checking the target function each tick. // -// a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond) +// a.Never(func() bool { return false; }, time.Second, 10*time.Millisecond) func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -932,7 +1016,7 @@ func (a *Assertions) Never(condition func() bool, waitFor time.Duration, tick ti // Neverf asserts that the given condition doesn't satisfy in waitFor time, // periodically checking the target function each tick. // -// a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") +// a.Neverf(func() bool { return false; }, time.Second, 10*time.Millisecond, "error message %s", "formatted") func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -942,7 +1026,7 @@ func (a *Assertions) Neverf(condition func() bool, waitFor time.Duration, tick t // Nil asserts that the specified object is nil. // -// a.Nil(err) +// a.Nil(err) func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -952,7 +1036,7 @@ func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) { // Nilf asserts that the specified object is nil. // -// a.Nilf(err, "error message %s", "formatted") +// a.Nilf(err, "error message %s", "formatted") func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -980,10 +1064,10 @@ func (a *Assertions) NoDirExistsf(path string, msg string, args ...interface{}) // NoError asserts that a function returned no error (i.e. `nil`). // -// actualObj, err := SomeFunction() -// if a.NoError(err) { -// assert.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// if a.NoError(err) { +// assert.Equal(t, expectedObj, actualObj) +// } func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -993,10 +1077,10 @@ func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) { // NoErrorf asserts that a function returned no error (i.e. `nil`). // -// actualObj, err := SomeFunction() -// if a.NoErrorf(err, "error message %s", "formatted") { -// assert.Equal(t, expectedObj, actualObj) -// } +// actualObj, err := SomeFunction() +// if a.NoErrorf(err, "error message %s", "formatted") { +// assert.Equal(t, expectedObj, actualObj) +// } func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1025,9 +1109,9 @@ func (a *Assertions) NoFileExistsf(path string, msg string, args ...interface{}) // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // -// a.NotContains("Hello World", "Earth") -// a.NotContains(["Hello", "World"], "Earth") -// a.NotContains({"Hello": "World"}, "Earth") +// a.NotContains("Hello World", "Earth") +// a.NotContains(["Hello", "World"], "Earth") +// a.NotContains({"Hello": "World"}, "Earth") func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1038,9 +1122,9 @@ func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs // NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // -// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted") -// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted") -// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted") +// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted") +// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted") +// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted") func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1051,9 +1135,9 @@ func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg strin // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // -// if a.NotEmpty(obj) { -// assert.Equal(t, "two", obj[1]) -// } +// if a.NotEmpty(obj) { +// assert.Equal(t, "two", obj[1]) +// } func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1064,9 +1148,9 @@ func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) { // NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // -// if a.NotEmptyf(obj, "error message %s", "formatted") { -// assert.Equal(t, "two", obj[1]) -// } +// if a.NotEmptyf(obj, "error message %s", "formatted") { +// assert.Equal(t, "two", obj[1]) +// } func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1076,7 +1160,7 @@ func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface // NotEqual asserts that the specified values are NOT equal. // -// a.NotEqual(obj1, obj2) +// a.NotEqual(obj1, obj2) // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). @@ -1089,7 +1173,7 @@ func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndAr // NotEqualValues asserts that two objects are not equal even when converted to the same type // -// a.NotEqualValues(obj1, obj2) +// a.NotEqualValues(obj1, obj2) func (a *Assertions) NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1099,7 +1183,7 @@ func (a *Assertions) NotEqualValues(expected interface{}, actual interface{}, ms // NotEqualValuesf asserts that two objects are not equal even when converted to the same type // -// a.NotEqualValuesf(obj1, obj2, "error message %s", "formatted") +// a.NotEqualValuesf(obj1, obj2, "error message %s", "formatted") func (a *Assertions) NotEqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1109,7 +1193,7 @@ func (a *Assertions) NotEqualValuesf(expected interface{}, actual interface{}, m // NotEqualf asserts that the specified values are NOT equal. // -// a.NotEqualf(obj1, obj2, "error message %s", "formatted") +// a.NotEqualf(obj1, obj2, "error message %s", "formatted") // // Pointer variable equality is determined based on the equality of the // referenced values (as opposed to the memory addresses). @@ -1140,7 +1224,7 @@ func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...in // NotNil asserts that the specified object is not nil. // -// a.NotNil(err) +// a.NotNil(err) func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1150,7 +1234,7 @@ func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) { // NotNilf asserts that the specified object is not nil. // -// a.NotNilf(err, "error message %s", "formatted") +// a.NotNilf(err, "error message %s", "formatted") func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1160,7 +1244,7 @@ func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{} // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. // -// a.NotPanics(func(){ RemainCalm() }) +// a.NotPanics(func(){ RemainCalm() }) func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1170,7 +1254,7 @@ func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{} // NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. // -// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted") +// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted") func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1180,8 +1264,8 @@ func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args ...inte // NotRegexp asserts that a specified regexp does not match a string. // -// a.NotRegexp(regexp.MustCompile("starts"), "it's starting") -// a.NotRegexp("^start", "it's not starting") +// a.NotRegexp(regexp.MustCompile("starts"), "it's starting") +// a.NotRegexp("^start", "it's not starting") func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1191,8 +1275,8 @@ func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...in // NotRegexpf asserts that a specified regexp does not match a string. // -// a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") -// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") +// a.NotRegexpf(regexp.MustCompile("starts"), "it's starting", "error message %s", "formatted") +// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1202,7 +1286,7 @@ func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, arg // NotSame asserts that two pointers do not reference the same object. // -// a.NotSame(ptr1, ptr2) +// a.NotSame(ptr1, ptr2) // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1215,7 +1299,7 @@ func (a *Assertions) NotSame(expected interface{}, actual interface{}, msgAndArg // NotSamef asserts that two pointers do not reference the same object. // -// a.NotSamef(ptr1, ptr2, "error message %s", "formatted") +// a.NotSamef(ptr1, ptr2, "error message %s", "formatted") // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1229,7 +1313,7 @@ func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg stri // NotSubset asserts that the specified list(array, slice...) contains not all // elements given in the specified subset(array, slice...). // -// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1240,7 +1324,7 @@ func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs // NotSubsetf asserts that the specified list(array, slice...) contains not all // elements given in the specified subset(array, slice...). // -// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1266,7 +1350,7 @@ func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) { // Panics asserts that the code inside the specified PanicTestFunc panics. // -// a.Panics(func(){ GoCrazy() }) +// a.Panics(func(){ GoCrazy() }) func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1278,7 +1362,7 @@ func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) { // panics, and that the recovered panic value is an error that satisfies the // EqualError comparison. // -// a.PanicsWithError("crazy error", func(){ GoCrazy() }) +// a.PanicsWithError("crazy error", func(){ GoCrazy() }) func (a *Assertions) PanicsWithError(errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1290,7 +1374,7 @@ func (a *Assertions) PanicsWithError(errString string, f assert.PanicTestFunc, m // panics, and that the recovered panic value is an error that satisfies the // EqualError comparison. // -// a.PanicsWithErrorf("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +// a.PanicsWithErrorf("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") func (a *Assertions) PanicsWithErrorf(errString string, f assert.PanicTestFunc, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1301,7 +1385,7 @@ func (a *Assertions) PanicsWithErrorf(errString string, f assert.PanicTestFunc, // PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that // the recovered panic value equals the expected panic value. // -// a.PanicsWithValue("crazy error", func(){ GoCrazy() }) +// a.PanicsWithValue("crazy error", func(){ GoCrazy() }) func (a *Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1312,7 +1396,7 @@ func (a *Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFun // PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that // the recovered panic value equals the expected panic value. // -// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") func (a *Assertions) PanicsWithValuef(expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1322,7 +1406,7 @@ func (a *Assertions) PanicsWithValuef(expected interface{}, f assert.PanicTestFu // Panicsf asserts that the code inside the specified PanicTestFunc panics. // -// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted") +// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted") func (a *Assertions) Panicsf(f assert.PanicTestFunc, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1332,8 +1416,8 @@ func (a *Assertions) Panicsf(f assert.PanicTestFunc, msg string, args ...interfa // Positive asserts that the specified element is positive // -// a.Positive(1) -// a.Positive(1.23) +// a.Positive(1) +// a.Positive(1.23) func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1343,8 +1427,8 @@ func (a *Assertions) Positive(e interface{}, msgAndArgs ...interface{}) { // Positivef asserts that the specified element is positive // -// a.Positivef(1, "error message %s", "formatted") -// a.Positivef(1.23, "error message %s", "formatted") +// a.Positivef(1, "error message %s", "formatted") +// a.Positivef(1.23, "error message %s", "formatted") func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1354,8 +1438,8 @@ func (a *Assertions) Positivef(e interface{}, msg string, args ...interface{}) { // Regexp asserts that a specified regexp matches a string. // -// a.Regexp(regexp.MustCompile("start"), "it's starting") -// a.Regexp("start...$", "it's not starting") +// a.Regexp(regexp.MustCompile("start"), "it's starting") +// a.Regexp("start...$", "it's not starting") func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1365,8 +1449,8 @@ func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...inter // Regexpf asserts that a specified regexp matches a string. // -// a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") -// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") +// a.Regexpf(regexp.MustCompile("start"), "it's starting", "error message %s", "formatted") +// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1376,7 +1460,7 @@ func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args . // Same asserts that two pointers reference the same object. // -// a.Same(ptr1, ptr2) +// a.Same(ptr1, ptr2) // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1389,7 +1473,7 @@ func (a *Assertions) Same(expected interface{}, actual interface{}, msgAndArgs . // Samef asserts that two pointers reference the same object. // -// a.Samef(ptr1, ptr2, "error message %s", "formatted") +// a.Samef(ptr1, ptr2, "error message %s", "formatted") // // Both arguments must be pointer variables. Pointer variable sameness is // determined based on the equality of both type and value. @@ -1403,7 +1487,7 @@ func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, // Subset asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // -// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1414,7 +1498,7 @@ func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ... // Subsetf asserts that the specified list(array, slice...) contains all // elements given in the specified subset(array, slice...). // -// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1424,7 +1508,7 @@ func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, a // True asserts that the specified value is true. // -// a.True(myBool) +// a.True(myBool) func (a *Assertions) True(value bool, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1434,7 +1518,7 @@ func (a *Assertions) True(value bool, msgAndArgs ...interface{}) { // Truef asserts that the specified value is true. // -// a.Truef(myBool, "error message %s", "formatted") +// a.Truef(myBool, "error message %s", "formatted") func (a *Assertions) Truef(value bool, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1444,7 +1528,7 @@ func (a *Assertions) Truef(value bool, msg string, args ...interface{}) { // WithinDuration asserts that the two times are within duration delta of each other. // -// a.WithinDuration(time.Now(), time.Now(), 10*time.Second) +// a.WithinDuration(time.Now(), time.Now(), 10*time.Second) func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1454,7 +1538,7 @@ func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta // WithinDurationf asserts that the two times are within duration delta of each other. // -// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") +// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1462,6 +1546,26 @@ func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta WithinDurationf(a.t, expected, actual, delta, msg, args...) } +// WithinRange asserts that a time is within a time range (inclusive). +// +// a.WithinRange(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second)) +func (a *Assertions) WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + WithinRange(a.t, actual, start, end, msgAndArgs...) +} + +// WithinRangef asserts that a time is within a time range (inclusive). +// +// a.WithinRangef(time.Now(), time.Now().Add(-time.Second), time.Now().Add(time.Second), "error message %s", "formatted") +func (a *Assertions) WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + WithinRangef(a.t, actual, start, end, msg, args...) +} + // YAMLEq asserts that two YAML strings are equivalent. func (a *Assertions) YAMLEq(expected string, actual string, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { diff --git a/vendor/github.com/stretchr/testify/suite/doc.go b/vendor/github.com/stretchr/testify/suite/doc.go index f91a245d..8d55a3aa 100644 --- a/vendor/github.com/stretchr/testify/suite/doc.go +++ b/vendor/github.com/stretchr/testify/suite/doc.go @@ -29,37 +29,38 @@ // Suite object has assertion methods. // // A crude example: -// // Basic imports -// import ( -// "testing" -// "github.com/stretchr/testify/assert" -// "github.com/stretchr/testify/suite" -// ) // -// // Define the suite, and absorb the built-in basic suite -// // functionality from testify - including a T() method which -// // returns the current testing context -// type ExampleTestSuite struct { -// suite.Suite -// VariableThatShouldStartAtFive int -// } +// // Basic imports +// import ( +// "testing" +// "github.com/stretchr/testify/assert" +// "github.com/stretchr/testify/suite" +// ) // -// // Make sure that VariableThatShouldStartAtFive is set to five -// // before each test -// func (suite *ExampleTestSuite) SetupTest() { -// suite.VariableThatShouldStartAtFive = 5 -// } +// // Define the suite, and absorb the built-in basic suite +// // functionality from testify - including a T() method which +// // returns the current testing context +// type ExampleTestSuite struct { +// suite.Suite +// VariableThatShouldStartAtFive int +// } // -// // All methods that begin with "Test" are run as tests within a -// // suite. -// func (suite *ExampleTestSuite) TestExample() { -// assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive) -// suite.Equal(5, suite.VariableThatShouldStartAtFive) -// } +// // Make sure that VariableThatShouldStartAtFive is set to five +// // before each test +// func (suite *ExampleTestSuite) SetupTest() { +// suite.VariableThatShouldStartAtFive = 5 +// } // -// // In order for 'go test' to run this suite, we need to create -// // a normal test function and pass our suite to suite.Run -// func TestExampleTestSuite(t *testing.T) { -// suite.Run(t, new(ExampleTestSuite)) -// } +// // All methods that begin with "Test" are run as tests within a +// // suite. +// func (suite *ExampleTestSuite) TestExample() { +// assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive) +// suite.Equal(5, suite.VariableThatShouldStartAtFive) +// } +// +// // In order for 'go test' to run this suite, we need to create +// // a normal test function and pass our suite to suite.Run +// func TestExampleTestSuite(t *testing.T) { +// suite.Run(t, new(ExampleTestSuite)) +// } package suite diff --git a/vendor/github.com/stretchr/testify/suite/interfaces.go b/vendor/github.com/stretchr/testify/suite/interfaces.go index 8b98a8af..fed037d7 100644 --- a/vendor/github.com/stretchr/testify/suite/interfaces.go +++ b/vendor/github.com/stretchr/testify/suite/interfaces.go @@ -7,6 +7,7 @@ import "testing" type TestingSuite interface { T() *testing.T SetT(*testing.T) + SetS(suite TestingSuite) } // SetupAllSuite has a SetupSuite method, which will run before the @@ -51,3 +52,15 @@ type AfterTest interface { type WithStats interface { HandleStats(suiteName string, stats *SuiteInformation) } + +// SetupSubTest has a SetupSubTest method, which will run before each +// subtest in the suite. +type SetupSubTest interface { + SetupSubTest() +} + +// TearDownSubTest has a TearDownSubTest method, which will run after +// each subtest in the suite have been run. +type TearDownSubTest interface { + TearDownSubTest() +} diff --git a/vendor/github.com/stretchr/testify/suite/suite.go b/vendor/github.com/stretchr/testify/suite/suite.go index b9b5d1c5..8b4202d8 100644 --- a/vendor/github.com/stretchr/testify/suite/suite.go +++ b/vendor/github.com/stretchr/testify/suite/suite.go @@ -7,6 +7,7 @@ import ( "reflect" "regexp" "runtime/debug" + "sync" "testing" "time" @@ -21,24 +22,41 @@ var matchMethod = flag.String("testify.m", "", "regular expression to select tes // retrieving the current *testing.T context. type Suite struct { *assert.Assertions + + mu sync.RWMutex require *require.Assertions t *testing.T + + // Parent suite to have access to the implemented methods of parent struct + s TestingSuite } // T retrieves the current *testing.T context. func (suite *Suite) T() *testing.T { + suite.mu.RLock() + defer suite.mu.RUnlock() return suite.t } // SetT sets the current *testing.T context. func (suite *Suite) SetT(t *testing.T) { + suite.mu.Lock() + defer suite.mu.Unlock() suite.t = t suite.Assertions = assert.New(t) suite.require = require.New(t) } +// SetS needs to set the current test suite as parent +// to get access to the parent methods +func (suite *Suite) SetS(s TestingSuite) { + suite.s = s +} + // Require returns a require context for suite. func (suite *Suite) Require() *require.Assertions { + suite.mu.Lock() + defer suite.mu.Unlock() if suite.require == nil { suite.require = require.New(suite.T()) } @@ -51,14 +69,20 @@ func (suite *Suite) Require() *require.Assertions { // assert.Assertions with require.Assertions), this method is provided so you // can call `suite.Assert().NoError()`. func (suite *Suite) Assert() *assert.Assertions { + suite.mu.Lock() + defer suite.mu.Unlock() if suite.Assertions == nil { suite.Assertions = assert.New(suite.T()) } return suite.Assertions } -func failOnPanic(t *testing.T) { +func recoverAndFailOnPanic(t *testing.T) { r := recover() + failOnPanic(t, r) +} + +func failOnPanic(t *testing.T, r interface{}) { if r != nil { t.Errorf("test panicked: %v\n%s", r, debug.Stack()) t.FailNow() @@ -71,7 +95,18 @@ func failOnPanic(t *testing.T) { // Provides compatibility with go test pkg -run TestSuite/TestName/SubTestName. func (suite *Suite) Run(name string, subtest func()) bool { oldT := suite.T() - defer suite.SetT(oldT) + + if setupSubTest, ok := suite.s.(SetupSubTest); ok { + setupSubTest.SetupSubTest() + } + + defer func() { + suite.SetT(oldT) + if tearDownSubTest, ok := suite.s.(TearDownSubTest); ok { + tearDownSubTest.TearDownSubTest() + } + }() + return oldT.Run(name, func(t *testing.T) { suite.SetT(t) subtest() @@ -81,9 +116,10 @@ func (suite *Suite) Run(name string, subtest func()) bool { // Run takes a testing suite and runs all of the tests attached // to it. func Run(t *testing.T, suite TestingSuite) { - defer failOnPanic(t) + defer recoverAndFailOnPanic(t) suite.SetT(t) + suite.SetS(suite) var suiteSetupDone bool @@ -126,10 +162,12 @@ func Run(t *testing.T, suite TestingSuite) { F: func(t *testing.T) { parentT := suite.T() suite.SetT(t) - defer failOnPanic(t) + defer recoverAndFailOnPanic(t) defer func() { + r := recover() + if stats != nil { - passed := !t.Failed() + passed := !t.Failed() && r == nil stats.end(method.Name, passed) } @@ -142,6 +180,7 @@ func Run(t *testing.T, suite TestingSuite) { } suite.SetT(parentT) + failOnPanic(t, r) }() if setupTestSuite, ok := suite.(SetupTestSuite); ok { diff --git a/vendor/modules.txt b/vendor/modules.txt index 0be11813..2235268a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -58,6 +58,9 @@ github.com/mattn/go-isatty # github.com/mitchellh/mapstructure v1.5.0 ## explicit; go 1.14 github.com/mitchellh/mapstructure +# github.com/netbox-community/go-netbox/v3 v3.7.1-alpha.0 +## explicit; go 1.18 +github.com/netbox-community/go-netbox/v3 # github.com/pmezard/go-difflib v1.0.0 ## explicit github.com/pmezard/go-difflib/difflib @@ -82,8 +85,8 @@ github.com/spf13/cobra/doc # github.com/spf13/pflag v1.0.5 ## explicit; go 1.12 github.com/spf13/pflag -# github.com/stretchr/testify v1.7.1 -## explicit; go 1.13 +# github.com/stretchr/testify v1.8.4 +## explicit; go 1.20 github.com/stretchr/testify/assert github.com/stretchr/testify/require github.com/stretchr/testify/suite