0.2.55 - Remote config/Request fixes
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRemoteConfigDefaultsAreComplete(t *testing.T) {
|
||||
document, err := loadRemoteConfig("")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if document.SchemaVersion != 1 || document.ConfigVersion != 1 {
|
||||
t.Fatalf("unexpected versions: %+v", document)
|
||||
}
|
||||
if document.Copy.Navigation.Favourites != "Favourites" {
|
||||
t.Fatalf("favourites label = %q", document.Copy.Navigation.Favourites)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoteConfigRejectsMalformedAndUnsafeDocuments(t *testing.T) {
|
||||
document := DefaultRemoteConfig()
|
||||
document.Presentation.NavigationRailExpandedWidthDp = 500
|
||||
raw, err := json.Marshal(document)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := loadRemoteConfig(string(raw)); err == nil {
|
||||
t.Fatal("unsafe presentation value was accepted")
|
||||
}
|
||||
|
||||
if _, err := loadRemoteConfig(`{"schemaVersion":1,"unknown":true}`); err == nil {
|
||||
t.Fatal("unknown fields were accepted")
|
||||
}
|
||||
|
||||
document = DefaultRemoteConfig()
|
||||
document.MinimumAppVersion = "0.3.0"
|
||||
document.MaximumAppVersion = "0.2.54"
|
||||
raw, err = json.Marshal(document)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := loadRemoteConfig(string(raw)); err == nil {
|
||||
t.Fatal("reversed app-version bounds were accepted")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user