Skip to content
Snippets Groups Projects
Commit c01d6b1e authored by Dave Cameron's avatar Dave Cameron
Browse files

device_face is an integer enum, not boolean

parent 0ad0d8f2
Branches
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@ language: go
go:
- 1.x
before_install:
- go get github.com/golang/lint/golint
- go get github.com/golang/lint/golint github.com/stretchr/testify/assert
before_script:
- go get -d ./...
script:
......
......@@ -22,8 +22,7 @@ import (
)
func main() {
// Passing nil to this method results in all default values
c := client.NewHTTPClient(nil)
c := defaultClient()
rs, err := c.Dcim.DcimRacksList(nil, nil)
if err != nil {
......@@ -33,3 +32,10 @@ func main() {
fmt.Printf("%v\n", *(rs.Payload.Count))
}
func defaultClient() *client.NetBox {
// Passing nil to this method results in all default configuration for the client.
// That is, a client that connects to http://localhost:8000, and using default
// field formats. (e.g. remove '-' from json field names)
return client.NewHTTPClient(nil)
}
\ No newline at end of file
// +build integration
// Copyright 2018 The go-netbox Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"testing"
"fmt"
"github.com/digitalocean/go-netbox/netbox/client/dcim"
"github.com/digitalocean/go-netbox/netbox/models"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/runtime"
"github.com/stretchr/testify/assert"
)
// These tests assume a netbox running locally, with the netbox test fixtures loaded.
// This is achievable with the following netbox management commands, after install:
// python3 netbox/manage.py loaddata dcim extras ipam
// python3 netbox/manage.py runserver 0.0.0.0:8000 --insecure
func TestRetrieveDeviceList(t *testing.T) {
c := defaultClient()
list, err := c.Dcim.DcimDevicesList(nil, nil)
assert.NoError(t, err)
assert.EqualValues(t, 11, *list.Payload.Count)
}
func TestSubdeviceRole(t *testing.T) {
c := defaultClient()
role := true
manufacturerID := int64(1)
model := "Test model"
slug := "test-slug"
newDeviceType := &models.WritableDeviceType{
SubdeviceRole: &role,
Comments: "Test device type",
Manufacturer: &manufacturerID,
Model: &model,
Slug: &slug,
}
err := newDeviceType.Validate(strfmt.Default)
assert.NoError(t, err)
createRequest := dcim.NewDcimDeviceTypesCreateParams().WithData(newDeviceType)
createResponse, err := c.Dcim.DcimDeviceTypesCreate(createRequest, runtime.ClientAuthInfoWriterFunc(SetAuthenticationHeader))
assert.NoError(t, err)
newID := float64(createResponse.Payload.ID)
assert.NotEqual(t, 0, newID)
retrieveResponse, err := c.Dcim.DcimDeviceTypesList(dcim.NewDcimDeviceTypesListParams().WithIDIn(&newID), nil)
assert.NoError(t, err)
assert.EqualValues(t, 1, *retrieveResponse.Payload.Count)
assert.EqualValues(t, "Test device type", retrieveResponse.Payload.Results[0].Comments)
deleteRequest := dcim.NewDcimDeviceTypesDeleteParams().WithID(int64(newID))
_, err = c.Dcim.DcimDeviceTypesDelete(deleteRequest, runtime.ClientAuthInfoWriterFunc(SetAuthenticationHeader))
assert.NoError(t, err)
}
const apiToken = "7b4e1ceaaf93528a41e64d048090f7fe13ed16f4"
const authHeaderFormat = "Token %v"
func SetAuthenticationHeader(req runtime.ClientRequest, _ strfmt.Registry) error {
req.SetHeaderParam("Authorization", fmt.Sprintf(authHeaderFormat, apiToken))
return nil
}
......@@ -37,7 +37,7 @@ type DeviceFace struct {
// value
// Required: true
Value *bool `json:"value"`
Value *int64 `json:"value"`
}
// Validate validates this device face
......
......@@ -13985,7 +13985,7 @@
"type": "string"
},
"value": {
"type": "boolean",
"type": "integer",
"x-nullable": true
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment