Fix dummy return. Closes #34

This commit is contained in:
Roberto Abdelkader Martínez Pérez
2019-10-18 23:55:25 +02:00
parent ecfa3dfa74
commit 304276db47
2 changed files with 13 additions and 3 deletions
+2 -2
View File
@@ -24,13 +24,13 @@ func New() safeRouteList {
func (srl *safeRouteList) Append(r model.Route) model.Route {
srl.m.Lock()
r.Index = len(srl.rs)
srl.rs = append(srl.rs, r)
l := len(srl.rs)
srl.m.Unlock()
Server.Handler.(*mux.SwappableMux).Update(srl.Snapshot())
return model.Route{Index: l - 1}
return r
}
func (srl *safeRouteList) Snapshot() []model.Route {
+11 -1
View File
@@ -147,7 +147,17 @@ func TestSnapshotNonBlockingReadWithOtherReaders(t *testing.T) {
}
}
func TestAppendReturnsTheInsertedRoutedWithTheActualIndexWhenEmpty(t *testing.T) {
func TestAppendReturnsTheInsertedRouted(t *testing.T) {
srl := New()
r := srl.Append(model.Route{ID: "FOO"})
if r.ID != "FOO" {
t.Errorf(`ID of the returned route is not "FOO", but %q`, r.ID)
}
}
func TestAppendReturnsTheNumberedRoutesWhenEmpty(t *testing.T) {
srl := New()
r := srl.Append(model.Route{})