@@ -3,6 +3,7 @@ package rules_test
33import (
44 "os"
55 "path/filepath"
6+ "reflect"
67 "strings"
78 "testing"
89
@@ -20,9 +21,9 @@ func TestToJSHandlers_Empty(t *testing.T) {
2021
2122func TestToJSHandlers_SkipsIncompleteRules (t * testing.T ) {
2223 rules := []Rule {
23- {Match : "" , Browser : "Firefox" }, // no match
24- {Match : "example.com" , Browser : "" }, // no browser
25- {Match : "example.com" , Browser : "Safari" }, // valid
24+ {Match : [] string { "" } , Browser : "Firefox" }, // no match
25+ {Match : [] string { "example.com" } , Browser : "" }, // no browser
26+ {Match : [] string { "example.com" } , Browser : "Safari" }, // valid
2627 }
2728 result := ToJSHandlers (rules )
2829 if len (result ) != 1 {
@@ -32,7 +33,7 @@ func TestToJSHandlers_SkipsIncompleteRules(t *testing.T) {
3233
3334func TestToJSHandlers_StringBrowser (t * testing.T ) {
3435 rules := []Rule {
35- {Match : "*github.com/*" , Browser : "Firefox" },
36+ {Match : [] string { "*github.com/*" } , Browser : "Firefox" },
3637 }
3738 result := ToJSHandlers (rules )
3839 if len (result ) != 1 {
@@ -49,7 +50,7 @@ func TestToJSHandlers_StringBrowser(t *testing.T) {
4950
5051func TestToJSHandlers_WithProfile (t * testing.T ) {
5152 rules := []Rule {
52- {Match : "*github.com/*" , Browser : "Google Chrome" , Profile : "Work" },
53+ {Match : [] string { "*github.com/*" } , Browser : "Google Chrome" , Profile : "Work" },
5354 }
5455 result := ToJSHandlers (rules )
5556 if len (result ) != 1 {
@@ -69,9 +70,9 @@ func TestToJSHandlers_WithProfile(t *testing.T) {
6970
7071func TestToJSHandlers_MultipleRules (t * testing.T ) {
7172 rules := []Rule {
72- {Match : "*github.com/*" , Browser : "Firefox" },
73- {Match : "https://linear.app/*" , Browser : "Google Chrome" , Profile : "Work" },
74- {Match : "example.com" , Browser : "Safari" },
73+ {Match : [] string { "*github.com/*" } , Browser : "Firefox" },
74+ {Match : [] string { "https://linear.app/*" } , Browser : "Google Chrome" , Profile : "Work" },
75+ {Match : [] string { "example.com" } , Browser : "Safari" },
7576 }
7677 result := ToJSHandlers (rules )
7778 if len (result ) != 3 {
@@ -86,7 +87,7 @@ func TestToJSHandlers_MultipleRules(t *testing.T) {
8687// ---- ToJSConfigScript ----
8788
8889func TestToJSConfigScript_DefaultBrowserFallback (t * testing.T ) {
89- rf := RulesFile {Rules : []Rule {{Match : "example.com" , Browser : "Firefox" }}}
90+ rf := RulesFile {Rules : []Rule {{Match : [] string { "example.com" } , Browser : "Firefox" }}}
9091 script , err := ToJSConfigScript (rf , "finickyConfig" )
9192 if err != nil {
9293 t .Fatal (err )
@@ -133,8 +134,8 @@ func TestLoadSave_RoundTrip(t *testing.T) {
133134 DefaultBrowser : "Firefox" ,
134135 DefaultProfile : "Work" ,
135136 Rules : []Rule {
136- {Match : "*github.com/*" , Browser : "Google Chrome" , Profile : "Personal" },
137- {Match : "https://linear.app/*" , Browser : "Safari" },
137+ {Match : [] string { "*github.com/*" } , Browser : "Google Chrome" , Profile : "Personal" },
138+ {Match : [] string { "https://linear.app/*" } , Browser : "Safari" },
138139 },
139140 }
140141
@@ -158,7 +159,7 @@ func TestLoadSave_RoundTrip(t *testing.T) {
158159 }
159160 for i , r := range original .Rules {
160161 got := loaded .Rules [i ]
161- if got .Match != r .Match || got .Browser != r .Browser || got .Profile != r .Profile {
162+ if ! reflect . DeepEqual ( got .Match , r .Match ) || got .Browser != r .Browser || got .Profile != r .Profile {
162163 t .Errorf ("Rule[%d]: got %+v, want %+v" , i , got , r )
163164 }
164165 }
0 commit comments