From 3189ef20c7b69e844ad13e03116b7bed4cddb76a Mon Sep 17 00:00:00 2001 From: breel Date: Sat, 25 Jul 2020 03:28:39 -0600 Subject: [PATCH] Add tests, stop omitting connections to skip a problem --- deploy.sh | 4 +++- storage/entity/one.go | 2 +- view/who_test.go | 13 ++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/deploy.sh b/deploy.sh index 07072c7..6540f41 100644 --- a/deploy.sh +++ b/deploy.sh @@ -3,7 +3,9 @@ function main() { cd "$(dirname "$BASH_SOURCE")" set -e - go test ./... + if [ -z "$NOTEST" ]; then + go test ./... + fi GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=0 go build -o $(basename "$PWD") -a -installsuffix cgo scp ./public/swagger/* zach@tickle.lan:./dndex/files/swagger/ scp ./dndex zach@tickle.lan:./dndex/dndex.new diff --git a/storage/entity/one.go b/storage/entity/one.go index 00cedf0..d1a66d0 100644 --- a/storage/entity/one.go +++ b/storage/entity/one.go @@ -27,7 +27,7 @@ type One struct { Text string `bson:"text,omitempty" json:"text,omitempty"` Relationship string `bson:"relationship,omitempty" json:"relationship,omitempty"` Modified int64 `bson:"modified,omitempty" json:"modified,omitempty"` - Connections map[string]One `bson:"connections,omitempty" json:"connections,omitempty"` + Connections map[string]One `bson:"connections" json:"connections,omitempty"` Attachments map[string]string `bson:"attachments,omitempty" json:"attachments,omitempty"` } diff --git a/view/who_test.go b/view/who_test.go index abdac35..5236ecb 100644 --- a/view/who_test.go +++ b/view/who_test.go @@ -387,7 +387,6 @@ func randomOne() entity.One { } } -//func sortOnes(ones []entity.One, r *http.Request) []entity.One { func TestSortOnes(t *testing.T) { oneA := entity.One{Name: "A", Title: "c", Modified: 2} oneB := entity.One{Name: "B", Title: "b", Modified: 1} @@ -412,6 +411,18 @@ func TestSortOnes(t *testing.T) { ones: []entity.One{oneA, oneB, oneC}, test: func(a, b entity.One) bool { return a.Modified >= b.Modified }, }, + "default: modified desc, custom entries": { + ones: []entity.One{ + entity.One{Modified: 2}, + entity.One{Modified: 5}, + entity.One{Modified: 7}, + entity.One{Modified: 3}, + entity.One{Modified: 4}, + entity.One{Modified: 1}, + entity.One{Modified: 6}, + }, + test: func(a, b entity.One) bool { return a.Modified >= b.Modified }, + }, "default=modified set=desc": { ones: []entity.One{oneA, oneB, oneC}, order: "-1",