Skip to content

Commit

Permalink
*: upgrade to Go 1.7, use subtests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlayher committed Sep 12, 2016
1 parent c9d38d2 commit 25e00cc
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: go
go:
- 1.6
- 1.7
before_install:
- go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
unifi [![GoDoc](http://godoc.org/github.com/mdlayher/unifi?status.svg)](http://godoc.org/github.com/mdlayher/unifi) [![Build Status](https://travis-ci.org/mdlayher/unifi.svg?branch=master)](https://travis-ci.org/mdlayher/unifi) [![Coverage Status](https://coveralls.io/repos/mdlayher/unifi/badge.svg?branch=master)](https://coveralls.io/r/mdlayher/unifi?branch=master) [![Report Card](http://goreportcard.com/badge/mdlayher/unifi)](http://goreportcard.com/report/mdlayher/unifi)
=====

Package `unifi` implements a client for the Ubiquiti UniFi Controller v4 API.
Package `unifi` implements a client for the Ubiquiti UniFi Controller v4 and v5 API.
MIT Licensed.
32 changes: 16 additions & 16 deletions alarms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,22 +119,22 @@ func TestAlarmUnmarshalJSON(t *testing.T) {
},
}

for i, tt := range tests {
t.Logf("[%02d] test %q", i, tt.desc)
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
a := new(Alarm)
err := a.UnmarshalJSON(tt.b)
if want, got := errStr(tt.err), errStr(err); !strings.Contains(got, want) {
t.Fatalf("unexpected error:\n- want: %v\n- got: %v",
want, got)
}
if err != nil {
return
}

a := new(Alarm)
err := a.UnmarshalJSON(tt.b)
if want, got := errStr(tt.err), errStr(err); !strings.Contains(got, want) {
t.Fatalf("unexpected error:\n- want: %v\n- got: %v",
want, got)
}
if err != nil {
continue
}

if want, got := tt.a, a; !reflect.DeepEqual(got, want) {
t.Fatalf("unexpected Alarm:\n- want: %+v\n- got: %+v",
want, got)
}
if want, got := tt.a, a; !reflect.DeepEqual(got, want) {
t.Fatalf("unexpected Alarm:\n- want: %+v\n- got: %+v",
want, got)
}
})
}
}
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Package unifi implements a client for the Ubiquiti UniFi Controller v4 API.
// Package unifi implements a client for the Ubiquiti UniFi Controller v4 and
// v5 API.
package unifi

import (
Expand Down
32 changes: 16 additions & 16 deletions devices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,22 @@ func TestDeviceUnmarshalJSON(t *testing.T) {
},
}

for i, tt := range tests {
t.Logf("[%02d] test %q", i, tt.desc)
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
d := new(Device)
err := d.UnmarshalJSON(tt.b)
if want, got := errStr(tt.err), errStr(err); !strings.Contains(got, want) {
t.Fatalf("unexpected error:\n- want: %v\n- got: %v",
want, got)
}
if err != nil {
return
}

d := new(Device)
err := d.UnmarshalJSON(tt.b)
if want, got := errStr(tt.err), errStr(err); !strings.Contains(got, want) {
t.Fatalf("unexpected error:\n- want: %v\n- got: %v",
want, got)
}
if err != nil {
continue
}

if want, got := tt.d, d; !reflect.DeepEqual(got, want) {
t.Fatalf("unexpected Device:\n- want: %+v\n- got: %+v",
want, got)
}
if want, got := tt.d, d; !reflect.DeepEqual(got, want) {
t.Fatalf("unexpected Device:\n- want: %+v\n- got: %+v",
want, got)
}
})
}
}
32 changes: 16 additions & 16 deletions stations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,22 @@ func TestStationUnmarshalJSON(t *testing.T) {
},
}

for i, tt := range tests {
t.Logf("[%02d] test %q", i, tt.desc)
for _, tt := range tests {
t.Run(tt.desc, func(t *testing.T) {
s := new(Station)
err := s.UnmarshalJSON(tt.b)
if want, got := errStr(tt.err), errStr(err); !strings.Contains(got, want) {
t.Fatalf("unexpected error:\n- want: %v\n- got: %v",
want, got)
}
if err != nil {
return
}

s := new(Station)
err := s.UnmarshalJSON(tt.b)
if want, got := errStr(tt.err), errStr(err); !strings.Contains(got, want) {
t.Fatalf("unexpected error:\n- want: %v\n- got: %v",
want, got)
}
if err != nil {
continue
}

if want, got := tt.s, s; !reflect.DeepEqual(got, want) {
t.Fatalf("unexpected Station:\n- want: %+v\n- got: %+v",
want, got)
}
if want, got := tt.s, s; !reflect.DeepEqual(got, want) {
t.Fatalf("unexpected Station:\n- want: %+v\n- got: %+v",
want, got)
}
})
}
}

0 comments on commit 25e00cc

Please sign in to comment.