Add test validating that settings in a bundle cannot be empty

This commit is contained in:
Benedikt Kulmann
2020-06-04 10:57:13 +02:00
parent cf02e53703
commit 4691cedb58

View File

@@ -61,7 +61,7 @@ type CustomError struct {
testing that saving a settings bundle and retrieving it again works correctly
using various setting bundle properties
*/
func TestSaveGetSettingsBundleWithNoSettings(t *testing.T) {
func TestSettingsBundleProperties(t *testing.T) {
type TestStruct struct {
testDataName string
BundleKey string
@@ -307,6 +307,31 @@ func TestSaveGetSettingsBundleWithNoSettings(t *testing.T) {
}
}
func TestSettingsBundleWithoutSettings(t *testing.T) {
client := service.Client()
cl := proto.NewBundleService("com.owncloud.api.settings", client)
createRequest := proto.SaveSettingsBundleRequest{
SettingsBundle: &proto.SettingsBundle{
Identifier: &proto.Identifier{
Extension: "great-extension",
BundleKey: "alices-bundle",
},
DisplayName: "Alice's Bundle",
},
}
response, err := cl.SaveSettingsBundle(context.Background(), &createRequest)
assert.Error(t, err)
assert.Nil(t, response)
var errorData CustomError
_ = json.Unmarshal([]byte(err.Error()), &errorData)
assert.Equal(t, "go.micro.client", errorData.ID)
assert.Equal(t, 500, errorData.Code)
assert.Equal(t, "settings: cannot be blank.", errorData.Detail)
assert.Equal(t, "Internal Server Error", errorData.Status)
_ = os.RemoveAll("ocis-settings-store")
}
/**
testing that setting getting and listing a settings bundle works correctly with a set of setting definitions
*/