cloud-game/pkg/worker/caged/libretro/manager/http_test.go
Sergey Stepanov 196930281b Add the initial caged apps abstraction
In the current version of the application, we have strictly hardcoded the captured runtime application (FFI Libretro frontend) as well as the streaming transport (WebRTC). This commit makes it possible to choose these components at runtime.

In this commit, we no longer manage initially connected users separately from the rooms, and instead, we treat all users as abstract app sessions, rather than hardcoded WebRTC connections. These sessions may contain all the transport specifics, such as WebRTC and so on.

Rooms, instead of having the hardcoded emulator app and WebRTC media encoders, now have these components decoupled. In theory, it is possible to add new transports (e.g., WebTransport) and streaming apps (e.g., wrapped into an ffmpeg desktop app).
2023-09-16 20:12:24 +03:00

56 lines
1.2 KiB
Go

package manager
import (
"reflect"
"testing"
"github.com/giongto35/cloud-game/v3/pkg/config"
)
func TestDiff(t *testing.T) {
tests := []struct {
declared []string
installed []string
diff []string
}{
{},
{
declared: []string{"a", "b"},
installed: []string{},
diff: []string{"a", "b"},
},
{
declared: []string{},
installed: []string{"c"},
},
{
declared: []string{"a", "b", "c"},
installed: []string{"c", "a", "b"},
},
{
declared: []string{"a", "b", "c"},
installed: []string{"c"},
diff: []string{"a", "b"},
},
{
declared: []string{"a", "b", "c", "c", "c", "a", "d"},
installed: []string{"c", "c", "c", "a", "a", "a"},
diff: []string{"b", "d"},
},
}
toCoreInfo := func(names []string) (r []config.CoreInfo) {
for _, n := range names {
r = append(r, config.CoreInfo{Name: n})
}
return
}
for _, test := range tests {
difference := diff(toCoreInfo(test.declared), toCoreInfo(test.installed))
if !reflect.DeepEqual(toCoreInfo(test.diff), difference) {
t.Errorf("wrong diff for %v <- %v = %v != %v",
test.declared, test.installed, test.diff, difference)
}
}
}