Timestamps on apps / routes (#614)

* route updated_at

* add app created at, fix some route updated_at bugs

* add app updated_at

TODO need to add tests through front end
TODO for validation we don't really want to use the validate wrapper since
it's a programmer error and not a user error, hopefully tests block this.

* add tests for timestamps to exist / change on apps&routes

* route equals at done, fix tests wit dis

* fix up the equals sugar

* add swagger

* fix rebase

* precisely allocate maps in clone

* vetted

* meh

* fix api tests
This commit is contained in:
Reed Allman
2017-12-23 09:57:36 -06:00
committed by GitHub
parent e1de38bbb5
commit f51792ae5e
23 changed files with 459 additions and 65 deletions

View File

@@ -4,7 +4,6 @@ import (
"bytes"
"context"
"log"
"reflect"
"testing"
"time"
@@ -289,7 +288,7 @@ func Test(t *testing.T, dsf func(t *testing.T) models.Datastore) {
if err != nil {
t.Fatalf("Test InsertApp: error when storing new app: %s", err)
}
if !reflect.DeepEqual(*inserted, *testApp) {
if !inserted.Equals(testApp) {
t.Fatalf("Test InsertApp: expected to insert:\n%v\nbut got:\n%v", testApp, inserted)
}
@@ -300,13 +299,12 @@ func Test(t *testing.T, dsf func(t *testing.T) models.Datastore) {
{
// Set a config var
updated, err := ds.UpdateApp(ctx,
&models.App{Name: testApp.Name, Config: map[string]string{"TEST": "1"}})
updated, err := ds.UpdateApp(ctx, &models.App{Name: testApp.Name, Config: map[string]string{"TEST": "1"}})
if err != nil {
t.Fatalf("Test UpdateApp: error when updating app: %v", err)
}
expected := &models.App{Name: testApp.Name, Config: map[string]string{"TEST": "1"}}
if !reflect.DeepEqual(*updated, *expected) {
if !updated.Equals(expected) {
t.Fatalf("Test UpdateApp: expected updated `%v` but got `%v`", expected, updated)
}
@@ -317,7 +315,7 @@ func Test(t *testing.T, dsf func(t *testing.T) models.Datastore) {
t.Fatalf("Test UpdateApp: error when updating app: %v", err)
}
expected = &models.App{Name: testApp.Name, Config: map[string]string{"TEST": "1", "OTHER": "TEST"}}
if !reflect.DeepEqual(*updated, *expected) {
if !updated.Equals(expected) {
t.Fatalf("Test UpdateApp: expected updated `%v` but got `%v`", expected, updated)
}
@@ -328,7 +326,7 @@ func Test(t *testing.T, dsf func(t *testing.T) models.Datastore) {
t.Fatalf("Test UpdateApp: error when updating app: %v", err)
}
expected = &models.App{Name: testApp.Name, Config: map[string]string{"OTHER": "TEST"}}
if !reflect.DeepEqual(*updated, *expected) {
if !updated.Equals(expected) {
t.Fatalf("Test UpdateApp: expected updated `%v` but got `%v`", expected, updated)
}
}
@@ -496,9 +494,8 @@ func Test(t *testing.T, dsf func(t *testing.T) models.Datastore) {
if err != nil {
t.Fatalf("Test GetRoute: unexpected error %v", err)
}
var expected models.Route = *testRoute
if !reflect.DeepEqual(*route, expected) {
t.Fatalf("Test InsertApp: expected to insert:\n%v\nbut got:\n%v", expected, *route)
if !route.Equals(testRoute) {
t.Fatalf("Test InsertApp: expected to insert:\n%v\nbut got:\n%v", testRoute, *route)
}
}
@@ -545,7 +542,7 @@ func Test(t *testing.T, dsf func(t *testing.T) models.Datastore) {
"Third": []string{"test", "test2"},
},
}
if !reflect.DeepEqual(*updated, *expected) {
if !updated.Equals(expected) {
t.Fatalf("Test UpdateRoute: expected updated `%v` but got `%v`", expected, updated)
}
@@ -586,7 +583,7 @@ func Test(t *testing.T, dsf func(t *testing.T) models.Datastore) {
"Third": []string{"test", "test2"},
},
}
if !reflect.DeepEqual(*updated, *expected) {
if !updated.Equals(expected) {
t.Fatalf("Test UpdateRoute: expected updated:\n`%v`\nbut got:\n`%v`", expected, updated)
}
}