mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-10-22 20:01:25 +00:00
fix(nodes): include known default scope in list responses
This commit is contained in:
1 parent
eda1f3c25e
commit
835d1cdd48
2 files changed
+13
No files matched your search
@@ -127,6 +127,7 @@ func (s *Store) ListNodes(ctx context.Context, nodeType int16, iatas []string, s
|
||||
Longitude: v.Longitude,
|
||||
IsObserver: v.IsObserver,
|
||||
ObserverID: nullableUUID(v.ObserverID),
|
||||
DefaultScope: v.DefaultScopeName,
|
||||
KnownNeighborCount: v.KnownNeighborCount,
|
||||
NeighborIDs: v.NeighborIds,
|
||||
Stale: v.LastSeen.Valid && v.LastSeen.Time.Before(time.Now().Add(-s.staleThreshold)),
|
||||
|
||||
@@ -706,3 +706,15 @@ func TestDeleteOldNodes(t *testing.T) {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestListNodes_DefaultScopePreservesCaseAndMissingValue(t *testing.T) {
|
||||
ctrl := gomock.NewController(t)
|
||||
mock := mockdb.NewMockQuerier(ctrl)
|
||||
scope := "#YOW"
|
||||
mock.EXPECT().ListNodes(gomock.Any(), gomock.Any()).Return([]sqlc.ListNodesRow{{DefaultScopeName: &scope}, {}}, nil)
|
||||
store := &Store{q: mock}
|
||||
page, err := store.ListNodes(context.Background(), 0, nil, nil, nil, nil, "", "", "", 0, 10, false)
|
||||
if err != nil || len(page.Items) != 2 || page.Items[0].DefaultScope == nil || *page.Items[0].DefaultScope != scope || page.Items[1].DefaultScope != nil {
|
||||
t.Fatalf("scope metadata lost or invented: %+v %v", page, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user