0.3.21
This commit is contained in:
@@ -89,6 +89,43 @@ func TestAppFontFamilyIsAValidatedGlobalConfiguration(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestDetailExperienceResolvesDeviceThenUserThenGlobalThenDefault(t *testing.T) {
|
||||
sess := store.Session{EmbyUserID: "user-1", DeviceID: "device-1"}
|
||||
if got := detailExperienceFor(store.DefaultFeaturePolicy(), sess); got != "v1" {
|
||||
t.Fatalf("default detail experience = %q, want v1", got)
|
||||
}
|
||||
global := store.FeaturePolicy{Values: map[string]json.RawMessage{"detailExperience": json.RawMessage(`"v2"`)}}
|
||||
if got := detailExperienceFor(global, sess); got != "v2" {
|
||||
t.Fatalf("global detail experience = %q, want v2", got)
|
||||
}
|
||||
perUser := store.FeaturePolicy{
|
||||
Values: map[string]json.RawMessage{"detailExperience": json.RawMessage(`"v2"`)},
|
||||
UserValues: map[string]map[string]json.RawMessage{"user-1": {"detailExperience": json.RawMessage(`"v1"`)}},
|
||||
}
|
||||
if got := detailExperienceFor(perUser, sess); got != "v1" {
|
||||
t.Fatalf("per-user detail experience = %q, want v1 to outrank the global v2", got)
|
||||
}
|
||||
perDevice := store.FeaturePolicy{
|
||||
UserValues: map[string]map[string]json.RawMessage{"user-1": {"detailExperience": json.RawMessage(`"v1"`)}},
|
||||
DeviceValues: map[string]map[string]json.RawMessage{"device-1": {"detailExperience": json.RawMessage(`"v2"`)}},
|
||||
}
|
||||
if got := detailExperienceFor(perDevice, sess); got != "v2" {
|
||||
t.Fatalf("per-device detail experience = %q, want v2 to outrank the per-user v1", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDetailExperienceFallsBackToV1OnAnUnrecognisedStoredValue(t *testing.T) {
|
||||
sess := store.Session{EmbyUserID: "user-1", DeviceID: "device-1"}
|
||||
garbage := store.FeaturePolicy{Values: map[string]json.RawMessage{"detailExperience": json.RawMessage(`"v3"`)}}
|
||||
if got := detailExperienceFor(garbage, sess); got != "v1" {
|
||||
t.Fatalf("garbage detail experience = %q, want v1", got)
|
||||
}
|
||||
notAString := store.FeaturePolicy{Values: map[string]json.RawMessage{"detailExperience": json.RawMessage(`42`)}}
|
||||
if got := detailExperienceFor(notAString, sess); got != "v1" {
|
||||
t.Fatalf("non-string detail experience = %q, want v1", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClientCapabilitiesAreNormalizedAndBounded(t *testing.T) {
|
||||
req := httptest.NewRequest(http.MethodGet, "/v1/status", nil)
|
||||
req.Header.Set("X-Memby-Capabilities", " Sonarr_Preroll_V1,server_features_v1,sonarr_preroll_v1,"+
|
||||
|
||||
Reference in New Issue
Block a user