Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

fix(tests): make plugin tests pass on windows

Gabe Kangas2a497ea3667b
diff --git a/pluginhost/pluginkv_test.go b/pluginhost/pluginkv_test.go
index 3fb0e5ffce..d8005eb660 100644
--- a/pluginhost/pluginkv_test.go
+++ b/pluginhost/pluginkv_test.go
@@ -14,6 +14,11 @@ func newTestDatastore(t *testing.T) *datastore.Datastore {
if err != nil {
t.Fatalf("setup datastore: %v", err)
}
+ t.Cleanup(func() {
+ if err := ds.DB.Close(); err != nil {
+ t.Errorf("close datastore DB: %v", err)
+ }
+ })
return ds
}
diff --git a/services/plugins/contract_test.go b/services/plugins/contract_test.go
index 374aa35ac6..18f559dae2 100644
--- a/services/plugins/contract_test.go
+++ b/services/plugins/contract_test.go
@@ -165,6 +165,10 @@ func marshalContract(t *testing.T, c contract) []byte {
return append(data, '\n')
}
+func normalizeNewlines(b []byte) []byte {
+ return []byte(strings.ReplaceAll(string(b), "\r\n", "\n"))
+}
+
func TestPluginContractMatchesSDK(t *testing.T) {
_, thisFile, _, _ := runtime.Caller(0)
repoRoot := filepath.Join(filepath.Dir(thisFile), "..", "..")
@@ -180,7 +184,7 @@ func TestPluginContractMatchesSDK(t *testing.T) {
t.Fatalf("read plugin-contract.json: %v", err)
}
- if string(gotJSON) != string(want) {
+ if string(normalizeNewlines(gotJSON)) != string(normalizeNewlines(want)) {
t.Errorf(`Owncast's bundled plugin runtime is out of sync with the plugin SDK.
The plugin host functions, permissions, or data shapes in services/plugins no