Skip to content

Commit

Permalink
proxy: add missing file
Browse files Browse the repository at this point in the history
rpc: add new helper tests
  • Loading branch information
Wessie committed Dec 25, 2024
1 parent 8d4376a commit 66b0ec7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions proxy/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package proxy

import (
"context"

radio "github.com/R-a-dio/valkyrie"
"github.com/R-a-dio/valkyrie/util/eventstream"
)

func (srv *Server) MetadataStream(ctx context.Context) (eventstream.Stream[radio.ProxyMetadataEvent], error) {
return srv.events.metaStream.SubStream(ctx), nil
}

func (srv *Server) SourceStream(ctx context.Context) (eventstream.Stream[radio.ProxySourceEvent], error) {
return srv.events.sourceStream.SubStream(ctx), nil
}
10 changes: 10 additions & 0 deletions rpc/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,15 @@ func TestRoundtrip(tt *testing.T) {
return assert.EqualExportedValues(tt, in, out)
}))

toAndFrom(tt, p, a, "proxy-metadata-event", toProtoProxyMetadataEvent, fromProtoProxyMetadataEvent)
toAndFrom(tt, p, a, "proxy-source-event", toProtoProxySourceEvent, fromProtoProxySourceEvent)

p.TestingRun(tt)
}

func toAndFrom[A any, B any](t *testing.T, p *gopter.Properties, a *arbitrary.Arbitraries, name string, to func(A) B, from func(B) A) {
p.Property(name, a.ForAll(func(in A) bool {
out := from(to(in))
return assert.EqualExportedValues(t, in, out)
}))
}

0 comments on commit 66b0ec7

Please sign in to comment.